19 #ifndef LUNCHBOX_MONITOR_H
20 #define LUNCHBOX_MONITOR_H
22 #include <lunchbox/nonCopyable.h>
23 #include <lunchbox/condition.h>
24 #include <lunchbox/scopedMutex.h>
48 explicit Monitor(
const T& value ) : _value( value ) {}
109 void set(
const T& value )
126 if(
sizeof( T ) <= 8 && _value == value )
129 while( _value != value )
141 if(
sizeof( T ) <= 8 )
143 const T current = _value;
144 if( current != value )
148 while( _value == value )
158 const T
waitNE(
const T& v1,
const T& v2 )
const
160 if(
sizeof( T ) <= 8 )
162 const T current = _value;
163 if( current != v1 && current != v2 )
167 while( _value == v1 || _value == v2 )
180 if(
sizeof( T ) <= 8 )
182 const T current = _value;
183 if( current >= value )
187 while( _value < value )
199 if(
sizeof( T ) <= 8 )
201 const T current = _value;
202 if( current <= value )
206 while( _value > value )
222 if(
sizeof( T ) <= 8 && _value == value )
226 while( _value != value )
246 if(
sizeof( T ) <= 8 && _value >= value )
250 while( _value < value )
269 if(
sizeof( T ) <= 8 && _value != value )
273 while( _value == value )
286 bool operator == (
const T& value )
const
289 return _value == value;
291 bool operator != (
const T& value )
const
294 return _value != value;
296 bool operator < (
const T& value )
const
299 return _value < value;
301 bool operator > (
const T& value )
const
304 return _value > value;
306 bool operator <= (
const T& value )
const
309 return _value <= value;
311 bool operator >= (
const T& value )
const
314 return _value >= value;
317 bool operator == (
const Monitor<T>& rhs )
const
320 return _value == rhs._value;
322 bool operator != (
const Monitor<T>& rhs )
const
325 return _value != rhs._value;
327 bool operator < ( const Monitor<T>& rhs )
const
330 return _value < rhs._value;
332 bool operator > (
const Monitor<T>& rhs )
const
335 return _value > rhs._value;
337 bool operator <= ( const Monitor<T>& rhs )
const
340 return _value <= rhs._value;
342 bool operator >= (
const Monitor<T>& rhs )
const
345 return _value >= rhs._value;
355 const T&
get()
const {
return _value; }
361 return _value + value;
368 return static_cast< T
>( _value | value );
375 return static_cast< T
>( _value & value );
388 template<
typename T >
392 os <<
"Monitor< " << monitor.
get() <<
" >";
426 #endif //LUNCHBOX_MONITOR_H