Is the database being updated by a separate process, or by another thread
in the same process?

If the former, I don't think you've any choice but to poll the database.
But by taking advantage of PRAGMA data_version and a clever schema you can
make that polling pretty lightweight. If you really don't want to sleep you
could use inotify or similar to only wake up after the database has been
written to, though the result will be significantly more complicated and
less portable; I'm not sure there's much value in it and it's certainly
getting off-topic for an sqlite mailing list.

If the latter then there's plenty of ways the thread updating the database
can notify the waiting thread, depending on your platform(s) and
language(s) of choice. But none of them really have anything to do with
sqlite either :)

-Rowan

On 2 May 2017 at 15:00, John Found <johnfo...@asm32.info> wrote:

> What is the best way (less CPU consuming) to put a thread in sleep and
> wake it up when new record has been written to a given table of SQLite
> database?
>
> Now I am implementing this by polling and time based sleep, but such
> solution is very dirty compromise, trading response time for CPU load. I
> want both. :)
>
> --
> http://fresh.flatassembler.net
> http://asm32.info
> John Found <johnfo...@asm32.info>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to