Switch listener to same incoming command handling as sender.
Rather than using a thread-safe queue, threads sending messages to listeners atomically reserve a message struct, write a command into it, and commit the command by writing the message ID into the listener thread's incoming command pipe. It polls on network IO and the command pipe, so commands wake it up. It reads the ID, processes the command written into l->msgs[ID], and atomically releases the message struct.
Loading
Please sign in to comment