mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-17 12:12:10 -04:00
add get_ptr(), set_ptr()
This commit is contained in:
parent
6f77ca5044
commit
afb1520ea1
@ -66,6 +66,33 @@ get(const PN_int32 &var) {
|
||||
return var;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AtomicAdjustDummyImpl::set_ptr
|
||||
// Access: Public, Static
|
||||
// Description: Atomically changes the indicated variable and
|
||||
// returns the original value.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void *AtomicAdjustDummyImpl::
|
||||
set_ptr(void *&var, void *new_value) {
|
||||
void *orig_value = var;
|
||||
var = new_value;
|
||||
return orig_value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AtomicAdjustDummyImpl::get_ptr
|
||||
// Access: Public, Static
|
||||
// Description: Atomically retrieves the snapshot value of the
|
||||
// indicated variable. This is the only guaranteed safe
|
||||
// way to retrieve the value that other threads might be
|
||||
// asynchronously setting, incrementing, or decrementing
|
||||
// (via other AtomicAjust methods).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void *AtomicAdjustDummyImpl::
|
||||
get_ptr(void * const &var) {
|
||||
return var;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AtomicAdjustDummyImpl::compare_and_exchange
|
||||
// Access: Public, Static
|
||||
|
@ -42,6 +42,9 @@ public:
|
||||
INLINE static PN_int32 set(PN_int32 &var, PN_int32 new_value);
|
||||
INLINE static PN_int32 get(const PN_int32 &var);
|
||||
|
||||
INLINE static void *set_ptr(void *&var, void *new_value);
|
||||
INLINE static void *get_ptr(void * const &var);
|
||||
|
||||
INLINE static PN_int32 compare_and_exchange(PN_int32 &mem,
|
||||
PN_int32 old_value,
|
||||
PN_int32 new_value);
|
||||
|
@ -76,6 +76,33 @@ get(const PN_int32 &var) {
|
||||
return var;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AtomicAdjustI386Impl::set_ptr
|
||||
// Access: Public, Static
|
||||
// Description: Atomically changes the indicated variable and
|
||||
// returns the original value.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void *AtomicAdjustI386Impl::
|
||||
set_ptr(void *&var, void *new_value) {
|
||||
void *orig_value = var;
|
||||
var = new_value;
|
||||
return orig_value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AtomicAdjustI386Impl::get_ptr
|
||||
// Access: Public, Static
|
||||
// Description: Atomically retrieves the snapshot value of the
|
||||
// indicated variable. This is the only guaranteed safe
|
||||
// way to retrieve the value that other threads might be
|
||||
// asynchronously setting, incrementing, or decrementing
|
||||
// (via other AtomicAjust methods).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void *AtomicAdjustI386Impl::
|
||||
get_ptr(void * const &var) {
|
||||
return var;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AtomicAdjustI386Impl::compare_and_exchange
|
||||
// Access: Public, Static
|
||||
|
@ -43,6 +43,9 @@ public:
|
||||
INLINE static PN_int32 set(PN_int32 &var, PN_int32 new_value);
|
||||
INLINE static PN_int32 get(const PN_int32 &var);
|
||||
|
||||
INLINE static void *set_ptr(void *&var, void *new_value);
|
||||
INLINE static void *get_ptr(void * const &var);
|
||||
|
||||
INLINE static PN_int32 compare_and_exchange(volatile PN_int32 &mem,
|
||||
PN_int32 old_value,
|
||||
PN_int32 new_value);
|
||||
|
@ -63,3 +63,28 @@ INLINE PN_int32 AtomicAdjustNsprImpl::
|
||||
get(const PN_int32 &var) {
|
||||
return var;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AtomicAdjustNsprImpl::set_ptr
|
||||
// Access: Public, Static
|
||||
// Description: Atomically changes the indicated variable and
|
||||
// returns the original value.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void *AtomicAdjustNsprImpl::
|
||||
set_ptr(void *&var, void *new_value) {
|
||||
return PR_AtomicSet((PN_int32 *)&var, (PN_int32)new_value);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AtomicAdjustNsprImpl::get_ptr
|
||||
// Access: Public, Static
|
||||
// Description: Atomically retrieves the snapshot value of the
|
||||
// indicated variable. This is the only guaranteed safe
|
||||
// way to retrieve the value that other threads might be
|
||||
// asynchronously setting, incrementing, or decrementing
|
||||
// (via other AtomicAjust methods).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void *AtomicAdjustNsprImpl::
|
||||
get_ptr(void * const &var) {
|
||||
return var;
|
||||
}
|
||||
|
@ -38,6 +38,9 @@ public:
|
||||
INLINE static bool dec(PN_int32 &var);
|
||||
INLINE static PN_int32 set(PN_int32 &var, PN_int32 new_value);
|
||||
INLINE static PN_int32 get(const PN_int32 &var);
|
||||
|
||||
INLINE static void *set_ptr(void *&var, void *new_value);
|
||||
INLINE static void *get_ptr(void * const &var);
|
||||
};
|
||||
|
||||
#include "atomicAdjustNsprImpl.I"
|
||||
|
@ -63,3 +63,30 @@ INLINE PN_int32 AtomicAdjustWin32Impl::
|
||||
get(const PN_int32 &var) {
|
||||
return var;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AtomicAdjustWin32Impl::set_ptr
|
||||
// Access: Public, Static
|
||||
// Description: Atomically changes the indicated variable and
|
||||
// returns the original value.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void *AtomicAdjustWin32Impl::
|
||||
set_ptr(void *&var, void *new_value) {
|
||||
void *orig_value = var;
|
||||
var = new_value;
|
||||
return orig_value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AtomicAdjustWin32Impl::get_ptr
|
||||
// Access: Public, Static
|
||||
// Description: Atomically retrieves the snapshot value of the
|
||||
// indicated variable. This is the only guaranteed safe
|
||||
// way to retrieve the value that other threads might be
|
||||
// asynchronously setting, incrementing, or decrementing
|
||||
// (via other AtomicAjust methods).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void *AtomicAdjustWin32Impl::
|
||||
get_ptr(void * const &var) {
|
||||
return var;
|
||||
}
|
||||
|
@ -39,6 +39,9 @@ public:
|
||||
INLINE static bool dec(PN_int32 &var);
|
||||
INLINE static PN_int32 set(PN_int32 &var, PN_int32 new_value);
|
||||
INLINE static PN_int32 get(const PN_int32 &var);
|
||||
|
||||
INLINE static void *set_ptr(void *&var, void *new_value);
|
||||
INLINE static void *get_ptr(void * const &var);
|
||||
};
|
||||
|
||||
#include "atomicAdjustWin32Impl.I"
|
||||
|
Loading…
x
Reference in New Issue
Block a user