Using boost, I start a thread from the main process as such.
MyWorkThread newThread;
newThread = boost::thread(newThread);
And in the worker thread class (MyWorkThread), I have a read function which reads from a USB device as much data as it can deliver. This function can be called several hundred times a second.
MyThread::read() }
//...
while () {
MyData data;
if (hasMore(dev, &data))
// lots of data here
// need to get it back to the main thread
}
}
}
I'm trying to figure out how to efficiently get this data back to the main process to be placed in a buffer since it can be called so often.
- Would making a callback to the main process be the way to go? If so, any pointers how using boost?
- Or should I just have a global data buffer and store it directly?