Beispiel #1
0
 void unlock()
 {
     if(!--recursion_count)
     {
         BOOST_INTERLOCKED_EXCHANGE(&locking_thread_id,0);
         mutex.unlock();
     }
 }
Beispiel #2
0
 bool try_timed_lock_for(long current_thread_id,D const& target)
 {
     if(mutex.try_lock_for(target))
     {
         BOOST_INTERLOCKED_EXCHANGE(&locking_thread_id,current_thread_id);
         recursion_count=1;
         return true;
     }
     return false;
 }
Beispiel #3
0
 void lock()
 {
     long const current_thread_id=win32::GetCurrentThreadId();
     if(!try_recursive_lock(current_thread_id))
     {
         mutex.lock();
         BOOST_INTERLOCKED_EXCHANGE(&locking_thread_id,current_thread_id);
         recursion_count=1;
     }
 }
Beispiel #4
0
 bool try_basic_lock(long current_thread_id)
 {
     if(mutex.try_lock())
     {
         BOOST_INTERLOCKED_EXCHANGE(&locking_thread_id,current_thread_id);
         recursion_count=1;
         return true;
     }
     return false;
 }
Beispiel #5
0
 bool try_timed_lock(long current_thread_id,::pdalboost::system_time const& target)
 {
     if(mutex.timed_lock(target))
     {
         BOOST_INTERLOCKED_EXCHANGE(&locking_thread_id,current_thread_id);
         recursion_count=1;
         return true;
     }
     return false;
 }
Beispiel #6
0
        bool try_lock()
        {
            HPX_ITT_SYNC_PREPARE(this);

#if !defined( BOOST_SP_HAS_SYNC )
            boost::uint64_t r = BOOST_INTERLOCKED_EXCHANGE(&v_, 1);
            BOOST_COMPILER_FENCE
#else
            boost::uint64_t r = __sync_lock_test_and_set(&v_, 1);
#endif

            if (r == 0) {
                HPX_ITT_SYNC_ACQUIRED(this);
                util::register_lock(this);
                return true;
            }

            HPX_ITT_SYNC_CANCEL(this);
            return false;
        }
Beispiel #7
0
 T exchange(T r, memory_order order=memory_order_seq_cst) volatile
 {
     return (T)BOOST_INTERLOCKED_EXCHANGE((long *)&i, (long)r);
 }
Beispiel #8
0
static inline void full_fence(void)
{
    long tmp;
    BOOST_INTERLOCKED_EXCHANGE(&tmp, 0);
}
Beispiel #9
0
//! Atomically loads and stores the 64-bit value
BOOST_FORCEINLINE void move64(const uint64_t* from, uint64_t* to)
{
    while (BOOST_INTERLOCKED_COMPARE_EXCHANGE(&g_spin_lock, 1, 0) != 0);
    *to = *from;
    BOOST_INTERLOCKED_EXCHANGE(&g_spin_lock, 0);
}
static inline long interlocked_exchange(long volatile* addend, long value)
{  return BOOST_INTERLOCKED_EXCHANGE(const_cast<long*>(addend), value);  }
Beispiel #11
0
 void unlock() { BOOST_INTERLOCKED_EXCHANGE(&locked, 0); }
Beispiel #12
0
 inline void interlocked_write_release(long volatile* x,long value)
 {
     BOOST_INTERLOCKED_EXCHANGE(x,value);
 }