memoryl...@tin.it schrieb: > My app is multithreaded ; the main() loop and some other working > threads, receiving / sending data and doing calculations. > > The question: what is the correct way to fire a graphics update from > a thread ?
We see, there are several correct ways. For measurements made by threads I'm using a list for buffering data. Some pseudocode: struct point { int x; int y; point(int px= 0, int py= 0): x(px), y(py) {} }; std::list< point > Buf critical_section CS; void Incoming(int x, int y) { // Buffering incoming data: CS.lock(); Buf.push_back(point(x, y)); CS.unlock(); } std::list< point > Outgoing() { // Calling buffered data std::list< point > OBuf CS.lock(); OBuf.swap(Buf); CS.unlock(); return OBuf; } while(!OBuf.empty()) { // Read points in original sequence: Use_Point(OBuf.front().x, OBuf.front().y); OBuf.pop_front(); } So data are coming in in threads speed and GUI is updated in "user speed", evaluating several data at once. This basic mechanism I'm using with several objects, from points to system states. _______________________________________________ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk