You are not logged in.
Pages: 1
Hi,
I'm writing a program using the Qt 4.3 toolkit.
My application is using many threads, which want to read/write from/to a single database. I thought of using an extra thread for the database handling to be able to work with a single database connection. But now I wonder how to communicate between the threads, without blocking one of them. Are signals and slots a good idea? Any ideas?
Offline
I guess it depends on what you're doing. Signals/slots is a good way to do it if order doesn't matter. Otherwise I'd wrap those calls with mutexes.
Offline
I don't want the calling threads to be blocked. Their purpose is socket communication and they should be responsive to the network. Telling the database thread to do something isn't the problem but getting the answer to the right thread. Is there something like IPC for threads (in Qt)?
Offline
dbus.
Offline
Can't use DBUS because it ought to be a cross-plattform application.
Anyway, thanks for the help.
Offline
dbus sux for possibly throughput intensive applications, one of standard patterns for such application is queue + mutex + semaphore. With mutex you guard accessing the queue, semaphore is used for signalling object being added to the queue. Thus value of semaphore is = to number of elements queued. Though you would have to pack requests in your own class and do (de)multiplexing.
Offline
The only other way I can think of is a priority queue.
Offline
Pages: 1