| | |
| | | using namespace bhome_msg; |
| | | using namespace bhome_shm; |
| | | |
| | | ShmSocket::ShmSocket(Shm &shm, const MQId &id, const int len) : |
| | | ShmSocket::ShmSocket(Shm &shm, const MQId id, const int len) : |
| | | run_(false), mq_(id, shm, len) |
| | | { |
| | | Start(); |
| | |
| | | onRecvWithPerMsgCB(*this, imsg, head); |
| | | } |
| | | }; |
| | | return mq().TryRecvAll(onMsg) > 0; // this will recv all msgs. |
| | | MsgI imsg; |
| | | return mq().TryRecv(imsg) ? (onMsg(imsg), true) : false; |
| | | }; |
| | | |
| | | try { |
| | |
| | | if (onIdle) { onIdle(*this); } |
| | | if (!more_to_send && !more_to_recv) { |
| | | std::this_thread::yield(); |
| | | using namespace std::chrono_literals; |
| | | std::this_thread::sleep_for(10000ns); |
| | | } |
| | | } catch (...) { |
| | | } |