dimanche 3 mai 2015

Non blocking way of adding a work item to array or list

After watching Herb Sutter's talk on concurrency in C++11 and 14 I got all excited about non blocking concurrency.

However, I've not yet been able to find a solution for what I considered a basic problem. So if this is already on here, please be gentile with me.

My problem is quite simple. I've got a worker thread running inside it's own class. And I keep a list of work items.

How do I add a work item in a lock free way.

The non lock free way of doing this would of course be to create a mutex. Lock it if you add an item and read(and lock of course) the list once the current work item is done.

I do not know how to do this in an lock free way however.

Aucun commentaire:

Enregistrer un commentaire