I want to implement a fast logger, that holds log entries, and when a certain trigger arrives, it flushes the last X messages.
So the idea is to hold all the messages in a cyclic buffer, and once we have the trigger, to push it's ID to a queue, which another thread monitors(one thread in all the system). this thread will go back X messages and to flush them. I know how to deal with messages that are being written while I am trying to flush, messages that have been overwritten before I flushed messages that being flushed while I am trying to update them etc.
My problem is, if for example I have 20 threads writing messages, and only 10 cores, in the time deference between 2 "writer" thread's execution, all the buffer will be overwritten several times.
Is there any way that "my" thread can "force" the "writer" thread to execute(or to give it it's time slice? I guess no but still... can you advice on any other way/design to overcome this problem.