Ultralite 12.0.1 for iOS When I synchronize my ultralite database, i'm performing it on a background thread using the shared connection I created when the database was initialized:
According to docs:
Because I am synchronizing on a different thread than my original shared connection I make when I create the database, should I create a new connection to the DB on each sync, then close the connection when sync has finished like such?
|
Yes, create a new connection for your synchronization. Once the database is running with your main connection, creating an additional connection is a lightweight operation. More detail: strictly speaking, the requirement is that only a single thread access a connection at a time, including retrieval of error information. So in theory, if you could guarantee no overlap, you could pass a connection between different threads. This usually isn't worth doing. There is a limit of 14 active connections on a database -- so you can't create new threads and connections without limit :-) Usually this would not make sense anyway - there aren't that many processor cores - and is solved by using an operation queue or the like with limited concurrency. |