mirror of
https://bitbucket.org/theswgsource/src-1.2.git
synced 2026-09-25 10:12:52 -04:00
Added sharedSynchronization library
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// InterlockedVoidPointer.h
|
||||
// Acy Stapp
|
||||
//
|
||||
// Copyright 6/19/2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_InterlockedVoidPointer_h
|
||||
#define INCLUDED_InterlockedVoidPointer_h
|
||||
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
class InterlockedVoidPointer
|
||||
{
|
||||
public:
|
||||
explicit InterlockedVoidPointer(void * initialValue=0);
|
||||
void * compareExchange(void * compare, void * exchange); // compare and exchange if same
|
||||
operator void * () const { return reinterpret_cast<void *>(value); }
|
||||
private:
|
||||
InterlockedVoidPointer(const InterlockedVoidPointer &o);
|
||||
InterlockedVoidPointer &operator =(const InterlockedVoidPointer &o);
|
||||
void * volatile value;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class InterlockedPointer: public InterlockedVoidPointer
|
||||
{
|
||||
public:
|
||||
explicit InterlockedPointer(T * initialValue): InterlockedVoidPointer(initialValue) {}
|
||||
operator T * () const { return static_cast<const T *>(value); }
|
||||
};
|
||||
|
||||
inline InterlockedVoidPointer::InterlockedVoidPointer(void * initialValue)
|
||||
{
|
||||
value = initialValue;
|
||||
}
|
||||
|
||||
inline void * InterlockedVoidPointer::compareExchange(void * compare, void * exchange)
|
||||
{
|
||||
return (void *)InterlockedCompareExchange((void **)&value, exchange, compare);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user