|
|
|
|
|
by jnordwick
663 days ago
|
|
The background thread can just sleep if no data in the queue. Since you are preprocessing the log messages and you know the minimum bounds. If the thread sleeps for 1 ms. Be generous and say you can at most push to the queue in 5ns, and if you know the largest messages you push will be 200 bytes, you can statically determine a 40M ring buffer will ensure enough space to sleep even at max rate with the largest messages. And that's just a simplstic scheme. If you have a pool logging structs so your queue is just a pointer to one of those, you can get away with much less even. And I can think of faster ways too. It isn't that difficult to get around using a semaphore |
|