Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » SQLite-insert/update in threads (please help!)
Re: SQLite-insert/update in threads (please help!) [message #27224 is a reply to message #27212] Tue, 06 July 2010 09:21 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13980
Registered: November 2005
Ultimate Member
Sc0rch wrote on Fri, 02 July 2010 15:24

I'm getting asserts of Fetch and Execute methods, sometimes. I don't know how to avoid them, but threads are really needed.

Some info about task:
- Console application.
- Main loop of program - RPC-server, with functions for user (each of functions use SQLite database, through global SQL)
- Threads registers incoming hardware events and writes them into the SQLite database.

How can I make this task threadsafe?



I would say that you should serialize (using Mutex) any access to global SQL - including creation of Sql cursors (where SQL is default parameter). I hope that would save the problem.

StaticMutex SQLMutex;


void MyThreadInsert() {
   Mutex::Lock __(SQLMutex);
   SQL * Insert(...)...
}

void MyGuiSelect() {
   Mutex::Lock __(SQLMutex);
   Sql sql;
   sql * Select(...
}


Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: MySQL bug: Missing FIELD_TYPE_TIMESTAMP
Next Topic: Oracle8: UTF8 charset Patch
Goto Forum:
  


Current Time: Tue May 21 18:06:37 CEST 2024

Total time taken to generate the page: 0.01284 seconds