Boost logo

Boost Users :

Subject: [Boost-users] Efficiently pass data from thread to main
From: Lane (software.research.development_at_[hidden])
Date: 2015-05-04 19:09:22


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?



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net