Re: [Cppcms-users] Threaded access to SQLite
Brought to you by:
artyom-beilis
From: Josh H. <jo...@ni...> - 2017-01-12 16:41:34
|
Artyom Beilis wrote: >> I have created a stand-alone test that shows the difference between >> sharing a single SQLite database connection between threads, and >> creating a new connection for each thread. It can be viewed here: >> >> https://gist.github.com/nispio/fe2955c9a0978532cf7b864a8b1b54db >> > > > Actually it shows exact behaviour I expected > > This is my run (note on PC with 4 cores): > > > SAME CONNECTION > Thread 1: library routine called out of sequence > Thread 2: library routine called out of sequence > Thread 3: library routine called out of sequence > FAILED run(insert_random, "/var/tmp/testdb1.db") > NEW CONNECTION > Thread 2: database is locked > Thread 3: database is locked > FAILED run(new_connection_insert_random, "/var/tmp/testdb2.db") > I'm sorry. I made a mistake when posting to Gist. I made a slight tweak to the code when posting, and forgot to check if it worked. (Rookie mistake, I know). The error that you are seeing in the first case is not related to threading at all; it is just a bad pointer. Will you please humor me and try one more time with the updated code? https://gist.github.com/nispio/fe2955c9a0978532cf7b864a8b1b54db |