From: chyujian <iam...@gm...> - 2011-06-09 06:17:30
|
I tried to build a multi-thread robot architecture using boost thread, but I found it quite difficult. Hereafter I past my code and my question inside. ###.h file### class Robot { public: Robot(); ~Robot(); void Read(); void Move(); }; ### .cc file ### Robot::Robot() { boost::thread readThread(&Robot::Read); /* I hope the read task to be implemented in a single independent thread. But once I set up the Read thread, I could not even pass the compile. How can I encapsulate the read task into a single thread? */ } void Robot::Read() { while(true) {/*read data from low level devices*/} } void Robot::Move() { /* set the velocity via the position2d device mounted on Robot*/ } |