Codemesh Runtime v3 C++ API Reference  3.9.205
xmog_atomic_pointer.h
1 //
2 // Copyright (c) 1999-2020 by Codemesh, Inc.. ALL RIGHTS RESERVED.
3 //
4 
5 
6 //All RIGHTS RESERVED.
7 #ifndef xmog_atomic_pointer_inc
8 #define xmog_atomic_pointer_inc
9 
10 
11 #include "xmog.h"
12 
13 
14 // This matches all the conditionals in xmog_atomic_pointer.cpp - if it
15 // ends up with no native atomic exchange, we use ACE stuff to implement it.
16 #if !((XMOG_WINDOWS == 1) || \
17  (defined (__GNUC__) && defined (__i386)) \
18  )
19 # define XMOG_NEED_TO_EMULATE_ATOMIC
20 #endif
21 
22 
26 class XMOG_DECLSPEC xmog_atomic_pointer
27 {
28 public:
29 
33  xmog_atomic_pointer() : value_( NULL ) {}
34 
40  xmog_atomic_pointer( void * p ) : value_( p ) {}
41 
48  xmog_atomic_pointer( const xmog_atomic_pointer & _rhs ) : value_( _rhs.value_ ) {}
49 
53  void * value() const
54  {
55  return (void*)value_;
56  }
57 
63  int operator == ( void * _rhs ) const
64  {
65  return value_ == _rhs;
66  }
67 
73  int operator != ( void * _rhs ) const
74  {
75  return value_ != _rhs;
76  }
77 
83  xmog_atomic_pointer & operator = ( void * _rhs );
84 
90  xmog_atomic_pointer & operator = ( xmog_atomic_pointer & _rhs );
91 
92 private:
93 
94  void * volatile value_;
95 };
96 
97 
98 #endif /* xmog_atomic_pointer_inc */
xmog_atomic_pointer::xmog_atomic_pointer
xmog_atomic_pointer(void *p)
Creates a pointer that is initialized to the given value.
Definition: xmog_atomic_pointer.h:40
xmog_atomic_pointer::xmog_atomic_pointer
xmog_atomic_pointer()
Creates a pointer that is initialized to NULL.
Definition: xmog_atomic_pointer.h:33
xmog_atomic_pointer::xmog_atomic_pointer
xmog_atomic_pointer(const xmog_atomic_pointer &_rhs)
Creates a pointer that is initialized to the same value as the given pointer.
Definition: xmog_atomic_pointer.h:48
xmog_atomic_pointer::value
void * value() const
Returns the pointer's value.
Definition: xmog_atomic_pointer.h:53
xmog_atomic_pointer
A utility class for thread safe compare exchange of pointer values.
Definition: xmog_atomic_pointer.h:26

Copyright (c) 1999-2020 by Codemesh, Inc., ALL RIGHTS RESERVED.