Re: [sqlite] Thread notification for new record in a table.

2017-05-03 Thread petern
FYI. I proposed a portable solution for a responsive interprocess work queue within SQLite without using native IPC less than 2 weeks ago on this very board. [See Dori the forgetful fish.] https://www.mail-archive.com/sqlite-users@mailinglists. sqlite.org/msg102741.html DB reader(s) block/poll u

Re: [sqlite] Thread notification for new record in a table.

2017-05-02 Thread Olivier Mascia
> Le 2 mai 2017 à 09:48, John Found a écrit : > >> Reading your question I assume a single, multi-threaded, application. You >> could write a SQL function (see sqlite3_create_function_v2 and associates) >> which signal an event. And add a SQL trigger calling this function when >> appropriate

Re: [sqlite] Thread notification for new record in a table.

2017-05-02 Thread John Found
On Tue, 2 May 2017 09:38:30 +0200 Olivier Mascia wrote: > > Le 2 mai 2017 à 09:00, John Found a écrit : > > > > 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 implemen

Re: [sqlite] Thread notification for new record in a table.

2017-05-02 Thread Olivier Mascia
> Le 2 mai 2017 à 09:00, John Found a écrit : > > 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 ver

Re: [sqlite] Thread notification for new record in a table.

2017-05-02 Thread Clemens Ladisch
Rowan Worth wrote: > Is the database being updated by a separate process, or by another thread > in the same process? > [...] > 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. If

Re: [sqlite] Thread notification for new record in a table.

2017-05-02 Thread Rowan Worth
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

[sqlite] Thread notification for new record in a table.

2017-05-02 Thread John Found
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 wa