ThreadQueue.cc
Go to the documentation of this file.
2 #include <cstring>
3 
4 namespace mf {
5  namespace service {
6 
8 
9  void
10  ThreadQueue::produce(OpCode const o, void* operand)
11  {
13  char* slot_p = static_cast<char*>(b.buffer());
14  void* v = operand;
15  std::memcpy(slot_p + 0, &o, sizeof(OpCode));
16  std::memcpy(slot_p + sizeof(OpCode), &v, sizeof(void*));
17  b.commit(buf_size);
18  } // runCommand
19 
20  void
21  ThreadQueue::consume(OpCode& opcode, void*& operand)
22  {
23  SingleConsumerQ::ConsumerBuffer b{m_buf}; // Look -- CONSUMER buffer
24  char* slot_p = static_cast<char*>(b.buffer());
25  std::memcpy(&opcode, slot_p + 0, sizeof(OpCode));
26  std::memcpy(&operand, slot_p + sizeof(OpCode), sizeof(void*));
27  b.commit(buf_size);
28  }
29 
30  } // end of namespace service
31 } // end of namespace mf
static constexpr int buf_size
Definition: ThreadQueue.h:28
SingleConsumerQ m_buf
Definition: ThreadQueue.h:29
static constexpr int buf_depth
Definition: ThreadQueue.h:27
void produce(OpCode opcode, void *operand)
Definition: ThreadQueue.cc:10
void consume(OpCode &opcode, void *&operand)
Definition: ThreadQueue.cc:21