What Platform are you on?

For UNIX platforms there may be a problem, see the comments in the os_unix.c file in the source directory, or here....

http://www.sqlite.org/cvstrac/getfile/sqlite/src/os_unix.c?v=1.41

....Though reading through things, wrapping arounb a MUTEX should be OK so long as there are no outstanding transactions (ie - you commit after inserting/updating/deleting a row and before releasing the mutex).

Also - under UNIX - if you are wrapping it around a MUTEX, you may want to do a "pthread_cond_wait" instead (or as well I should say) as that is cancellable should the thing hang.

Eddy


Cory Nelson wrote:
I understand you are supposed to open a new sqlite3 connection for
every thread that needs access, but- would it be safe to wrap access
to the database with a mutex?  I've got code that needs to insert at
random times (sometimes many times per sec) and select once per sec in
another thread.  The inserting can really get to CPU usage so i want
to wrap it in a transaction that is closed/opened every time the
select is performed.

If there is a better way, I'm open to that too :)




Reply via email to