PDA

View Full Version : Communication between QThread and boost threads



ustulation
11th February 2013, 07:22
The Gui is in Qt and Api is in boost. The Gui is meant to sit on top of Api. One of the functions of Api is to do network level data management, process data in certain ways and communicate with the Gui (ie., bridge Gui with other end of Api). To keep the GUI from freezing Api does it's work in a separate thread. If both Gui and Api had used Qt, communication would have been easier with cross-threaded signal-slot mechanism of Qt. Api emits and returns immediately and vice-versa. So none would be blocked unless explicitly specified (Qt::BlockingQueuedConnection). I've been using boost only since a while back as it was required to code new Api in boost. How do i achieve this mechanism in boost <--> Qt communication? Api is going to be header+static_library and so Gui and Api will produce single executable. I have to support Linux, Windows and Mac minimum.

wysota
11th February 2013, 08:39
It depends on how your API works, what it is supposed to do and what it is supposed to communicate to the UI. In general data exchange between threads requires synchronization using semaphores or similar mechanisms.