void unlock() { long const offset=lock_flag_value; long const old_count=BOOST_INTERLOCKED_EXCHANGE_ADD(&active_count,lock_flag_value); if(!(old_count&event_set_flag_value) && (old_count>offset)) { if(!win32::interlocked_bit_test_and_set(&active_count,event_set_flag_bit)) { win32::SetEvent(get_event()); } } }
T fetch_add(T c, memory_order order=memory_order_seq_cst) volatile { return (T)BOOST_INTERLOCKED_EXCHANGE_ADD((long *)&i, c); }
static inline long interlocked_exchange_add(long volatile* addend, long value) { return BOOST_INTERLOCKED_EXCHANGE_ADD(const_cast<long*>(addend), value); }