18 #ifndef INCLUDED_UHD_UTILS_ATOMIC_HPP    19 #define INCLUDED_UHD_UTILS_ATOMIC_HPP    23 #include <boost/thread/thread.hpp>    24 #include <boost/thread/mutex.hpp>    25 #include <boost/thread/condition_variable.hpp>    26 #include <boost/interprocess/detail/atomic.hpp>    28 #include <boost/version.hpp>    29 #define BOOST_IPC_DETAIL boost::interprocess::ipcdetail    43         UHD_INLINE boost::uint32_t 
cas(boost::uint32_t newval, boost::uint32_t cmp){
    44             return BOOST_IPC_DETAIL::atomic_cas32(&_num, newval, cmp);
    49             BOOST_IPC_DETAIL::atomic_write32(&_num, newval);
    54             return BOOST_IPC_DETAIL::atomic_read32(&_num);
    59             return BOOST_IPC_DETAIL::atomic_inc32(&_num);
    64             return BOOST_IPC_DETAIL::atomic_dec32(&_num);
    67     private: 
volatile boost::uint32_t _num;
    98             if (_size == 1) 
return;
   101             _entry_counter.inc();
   102             _entry_counter.cas(0, _size);
   103             boost::mutex::scoped_lock lock(_mutex);
   104             while (_entry_counter.read() != 0)
   106                 this->check_interrupt();
   107                 _cond.timed_wait(lock, boost::posix_time::milliseconds(1));
   114             _exit_counter.cas(0, _size);
   115             while (_exit_counter.read() != 0) this->check_interrupt();
   121             while (_entry_counter.read() != (_size-1)) this->check_interrupt();
   130         boost::condition_variable _cond;
   134             if (_done.
read() != 0) 
throw boost::thread_interrupted();
   135             boost::this_thread::interruption_point();
   136             boost::this_thread::yield();
   149         boost::uint32_t value,
   152         if (cond.
read() == value) 
return true;
   154         while (cond.
read() != value){
   156             boost::this_thread::interruption_point();
   157             boost::this_thread::yield();
 UHD_INLINE boost::uint32_t read(void)
Gets the current value of the atomic integer. 
Definition: atomic.hpp:53
 
UHD_INLINE void wait(void)
Wait on the barrier condition. 
Definition: atomic.hpp:96
 
UHD_INLINE void release(void)
Definition: atomic.hpp:172
 
Definition: atomic.hpp:74
 
Definition: time_spec.hpp:39
 
A 32-bit integer that can be atomically accessed. 
Definition: atomic.hpp:34
 
UHD_INLINE void wait_others(void)
Wait on the barrier condition. 
Definition: atomic.hpp:119
 
UHD_INLINE bool spin_wait_with_timeout(atomic_uint32_t &cond, boost::uint32_t value, const double timeout)
Definition: atomic.hpp:147
 
static time_spec_t get_system_time(void)
 
Definition: build_info.hpp:25
 
UHD_INLINE boost::uint32_t cas(boost::uint32_t newval, boost::uint32_t cmp)
Compare with cmp, swap with newval if same, return old value. 
Definition: atomic.hpp:43
 
UHD_INLINE bool claim_with_wait(const double timeout)
Definition: atomic.hpp:176
 
UHD_INLINE atomic_uint32_t(void)
Create a new atomic 32-bit integer, initialized to zero. 
Definition: atomic.hpp:38
 
UHD_INLINE void write(const boost::uint32_t newval)
Sets the atomic integer to a new value. 
Definition: atomic.hpp:48
 
UHD_INLINE boost::uint32_t inc(void)
Increment by 1 and return the old value. 
Definition: atomic.hpp:58
 
simple_claimer(void)
Definition: atomic.hpp:168
 
UHD_INLINE boost::uint32_t dec(void)
Decrement by 1 and return the old value. 
Definition: atomic.hpp:63
 
#define UHD_INLINE
Definition: config.h:63
 
void resize(const size_t size)
Resize the barrier for N threads. 
Definition: atomic.hpp:82
 
#define UHD_API
Definition: config.h:73
 
reusable_barrier(const size_t size)
Definition: atomic.hpp:79
 
Definition: atomic.hpp:166
 
reusable_barrier()
Definition: atomic.hpp:77
 
void interrupt(void)
Definition: atomic.hpp:90