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 up to a specified busy_timeout but are directly
synchronized to completion of the DB writer's transaction payload.

See: http://sqlite.org/c3ref/busy_timeout.html

Basically, Instead of sleep(), the reader(s) set busy_timeout().  Thus, the
polling interval can be very long without reducing responsiveness.




On Tue, May 2, 2017 at 12:48 AM, John Found <johnfo...@asm32.info> wrote:

> On Tue, 2 May 2017 09:38:30 +0200
> Olivier Mascia <o...@integral.be> wrote:
>
> > > Le 2 mai 2017 à 09:00, John Found <johnfo...@asm32.info> 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 very dirty compromise, trading response time for CPU load. I
> want both. :)
> > >
> > > --
> > > http://fresh.flatassembler.net
> > > http://asm32.info
> > > John Found <johnfo...@asm32.info>
> >
> > 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.
>
> In my case I have several running applications that write in the database.
> But isn't this solution applicable nevertheless? Maybe with some kind of
> IPC.
>
> >
> >
> > --
> > Best Regards, Meilleures salutations, Met vriendelijke groeten,
> > Olivier Mascia, http://integral.software
> >
> >
> >
> > _______________________________________________
> > sqlite-users mailing list
> > sqlite-users@mailinglists.sqlite.org
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
>
> --
> 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