Good day. We have:
1st stream - TCP C server with LibEvent;
2nd stream - processing queues and sending processed data to another server.

The server takes messages from certain devices and processes them (roughly speaking, each device has its own unique identifier), then adds them to the queue ( queue.h ).

The second stream in a constant loop looks at the presence of data in the queue and, if there is one, sends it to a third-party service and waits for an answer from it: either just "OK \ r \ n" or, if there is a message for this device, sends it back in sishny server.

So the question is: how best to implement sending messages received from a third-party service to the device?

As an option, send messages to a third-party service in the function callback reception of the message of the libevent (without putting them into the queue), but this seems to me not entirely rational.

Has anyone implemented this? Who can tell?

  • Just in case, the question is the queue, which is used to send messages from the first thread to the second one, is protected from simultaneous access by both threads? - Vladimir Gamalyan
  • Well, since you use an event approach (probably without heavy calculations), why not organize all the logic in one thread, I do not see anything irrational. - Vladimir Gamalyan

0