Page 1 of 1

SQLite threadmode...

Posted: Fri Aug 19, 2011 9:07 am
by DoubleDutch
Does anyone know what mode SQLite is supplied in with PB?
1. Single-thread. In this mode, all mutexes are disabled and SQLite is unsafe to use in more than a single thread at once.
2. Multi-thread. In this mode, SQLite can be safely used by multiple threads provided that no single database connection is used simultaneously in two or more threads.
3. Serialized. In serialized mode, SQLite can be safely used by multiple threads with no restriction.
Hopefully it is mode 3?

Re: SQLite threadmode...

Posted: Mon Sep 12, 2011 4:51 pm
by Num3
Good question!!

Even though it is stated in the Sqlite doc's that:
Threads are EVIL
:lol:

Re: SQLite threadmode...

Posted: Mon Sep 12, 2011 6:15 pm
by netmaestro
SQLite's doc does say that the default mode is serialized, so that seems promising.

Re: SQLite threadmode...

Posted: Mon Sep 12, 2011 11:02 pm
by freak
Currently the mode is 'serialized'.

I think this may be a bit overkill though, because the PB database library (and object system in general) are not prepared for multi-threaded access to the same object, so by pure PB means you cannot make use of the 'serialized' mode anyway. So we might change this to 'multi-thread' in the future. Might be interesting to see if this makes a significant speed difference.

Anyway, you can switch between 'multi-thread' and 'serialized' at runtime, so if you really need the 'serialized' mode, i suggest you call the appropriate function to explicitly set the 'serialized' mode and you should be safe for the future should we decide to change it (we won't change it to 'single-thread' as that won't work with the PB threadsafe mode).

Re: SQLite threadmode...

Posted: Wed Sep 14, 2011 9:30 am
by DoubleDutch
Thanks for the info. Maybe some docs on how to set the mode would be helpful in the help file for people who don't read this post... :)