The "bitmask" manipulation in v2/shared_mutex and v2/upgrade_mutex makes the code difficult to understand. The attached patch attempts to replace the bitmasks with more manageable "bitfields". This leads to shorter and more readable code with equivalent performance.

All "thread" tests still pass on my Win7/x64 computer with v2/shared_mutex.hpp manually included from thread/shared_mutex.hpp.

If the patch is appreciated, then I can also send a similar patch for v2/upgrade_mutex.

Regards,
Fredrik