First of all, these are very specialized, exotic type of sync algorithms
indeed! Keep that in the front of your mind wrt ever thinking about
using them directly: Think about danger when using them. Trust me, it
will keep you safer. However, by all means, if interested, learn all
about C++'s ability to provide the ability to implement these things
_before_ you use them for anything other than a "toy example test program".
I am sorry Bonita if my writings in some of my most recent threads came
across as if I am some sort of lock-free religious nut: I am not. If the
mutex version is working fine, by all means: keep using it!
Do not use these exotic algorithms unless you know what you are doing,
or perhaps just experimenting, for learning and fun. They can sometimes
come in handy when you need to scale up, think commercial database type
of loads...
Sorry for not making this clearer to Bonita. It seems as if I really
annoyed her! Sorry for the fact that I did not point these dangers out
for it seemed to make her teeth want to itch. I remember hearing that
phrase on this group when I posted some code with hardcore macros years
ago. ;^o
Now, on a side note: There are many ways to integrate locking and
non-blocking techniques that can be beneficial:
An Effective Marriage between Lock-Free and Lock-Based Algorithms
Can be a Good Thing!
One example is adding the ability of conditional blocking for basically
any lock-free algorithm, the eventcount, or sometimes even a fast-pathed
semaphore can accomplish this goal...
Fwiw, perhaps I should switch from posting the rest of my queue/stack
algorithms here, and go ahead and focus on how we can code a RCU like
mechanism in pure std C++. Instead of producer/consumer problem, I
should focus on the reader/writer problem. Thank you for challenging me
to begin with Bonita. :^)
FWIW, the RCU like std C++ algorithm I have in mind, coded as a Relacy
unit test:
http://www.1024cores.net/home/relacy-race-detector
(here is Relacy)
can be found here:
http://pastebin.com/raw/f71480694
https://groups.google.com/d/topic/lock-free/X3fuuXknQF0/discussion
(here is the discussion where I present the algorithm, please take the
time to read all)
Fwiw, here is a proxy collector I created with custom asm, older code:
http://webpages.charter.net/appcore/misc/pc_sample_h_v1.html
Again, sorry Bonita for not pointing out all of the caveats!
;^o
Can you forgive me?