Changes due to continue development of the IpcLibs. Not done yet.

This commit is contained in:
Juan Carlos Luciani
2006-09-01 05:37:43 +00:00
parent 4326223276
commit f45c0f4c9e
10 changed files with 64 additions and 215 deletions

View File

@@ -100,33 +100,45 @@ extern pthread_mutex_t interlockedMutex;
__inline static unsigned long
InterlockedIncrement(unsigned long *pValue)
{
unsigned long retVal;
pthread_mutex_lock(&interlockedMutex);
*pValue ++;
(*pValue) ++;
retVal = *pValue;
pthread_mutex_unlock(&interlockedMutex);
return retVal;
}
__inline static unsigned long
InterlockedDecrement(unsigned long *pValue)
{
unsigned long retVal;
pthread_mutex_lock(&interlockedMutex);
*pValue --;
(*pValue) --;
retVal = *pValue;
pthread_mutex_unlock(&interlockedMutex);
return retVal;
}
__inline static uint32_t
InterlockedIncrement(uint32_t *pValue)
{
uint32_t retVal;
pthread_mutex_lock(&interlockedMutex);
*pValue ++;
(*pValue) ++;
retVal = *pValue;
pthread_mutex_unlock(&interlockedMutex);
return retVal;
}
__inline static uint32_t
InterlockedDecrement(uint32_t *pValue)
{
uint32_t retVal;
pthread_mutex_lock(&interlockedMutex);
*pValue --;
(*pValue) --;
retVal = *pValue;
pthread_mutex_unlock(&interlockedMutex);
return retVal;
}
//===[ Include files ]=====================================================

View File

@@ -18,8 +18,6 @@
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
* Author: Juan Carlos Luciani <jluciani@novell.com>
*
***********************************************************************/
#ifndef SMARTPTR_H
@@ -56,12 +54,12 @@ class ObjRef
void IncRefCount(void)
{
InterlockedIncrement((unsigned long*)&m_Count);
InterlockedIncrement(&m_Count);
}
bool DecRefCount(void)
{
if ((m_Count > 0) && (InterlockedDecrement((unsigned long*)&m_Count) == 0))
if ((m_Count > 0) && (InterlockedDecrement(&m_Count) == 0))
{
return true;
}
@@ -81,9 +79,7 @@ class ObjRef
//
private:
// BUGBUG!! - Need to put a lock in here so the count can be updated atomically.
// or use an interlocked inc/dec if one exists.
mutable unsigned int m_Count;
mutable unsigned long m_Count;
};
@@ -273,8 +269,8 @@ inline void SmartPtr<T>::resetPtr(T* newPtr)
} // End of SmartPtr::resetPtr()
#endif // SMARTPTR_H
/******************************************************************************/
/******************************************************************************/