Christoph Schreiber
2010-11-30 14:37:49 UTC
Hi, I'm working on a multi-threaded image server and I have 2 questions:
1) How "expensive" is a call to sqlite3_open. Does a call to sqlite3_enable_shared_cache make it "cheaper"?
2) If sqlite3_open is an expensive operation then I would like to keep a list (cache) of open database connections (sqlite*'s). Here's how it *should* work: The main thread calls sqlite3_open a couple of times and pushes the resulting sqlite-handles into a concurrent queue. The worker thread then pops the handle from the queue, does what needs to be done and pushes the handle back. No sqlite-handle is used by more than one thread at the same time. Is that safe?
Cheers, Christoph
1) How "expensive" is a call to sqlite3_open. Does a call to sqlite3_enable_shared_cache make it "cheaper"?
2) If sqlite3_open is an expensive operation then I would like to keep a list (cache) of open database connections (sqlite*'s). Here's how it *should* work: The main thread calls sqlite3_open a couple of times and pushes the resulting sqlite-handles into a concurrent queue. The worker thread then pops the handle from the queue, does what needs to be done and pushes the handle back. No sqlite-handle is used by more than one thread at the same time. Is that safe?
Cheers, Christoph