We strive to use the free queue in our code to reduce the lock conflict between one producer and a consumer in our current implementation. There are many queue implementations, but I was not too clear how best to manage node memory management.
For example, a manufacturer is as follows:
queue.Add( new WorkUnit(...) );
And the consumer is as follows:
WorkUnit* unit = queue.RemoveFront();
unit->Execute();
delete unit;
We are currently using a memory pool for distribution. You will notice that the manufacturer allocates memory, and the consumer deletes it. Since we use pools, we need to add another lock to the memory pool in order to protect it correctly. This, apparently, in the first place denies the performance advantage of a lock-free queue.
So far, I think our options are:
, ? , .
.