__slotCapacity = DEFAULT_CAPACITY;
__pSlots = new _HandleElement[__slotCapacity];
- __pLock = new (std::nothrow) Tizen::Base::Runtime::Mutex();
- SysTryLog(NID_BASE, __pLock != null, "Failed to allocate the mutex instance");
-
- result r = __pLock->Create();
+ result r = __lock.Create();
SysTryLog(NID_BASE, !IsFailed(r), "Failed to create the mutex instance");
}
virtual ~_ObjectManagerImpl(void)
{
delete[] __pSlots;
- //delete __pLock;
}
/**
__pSlots[i] = objectManagerImpl.__pSlots[i];
}
- __pLock = new (std::nothrow) Tizen::Base::Runtime::Mutex();
- SysTryLog(NID_BASE, __pLock != null, "Failed to allocate the mutex instance");
-
- result r = __pLock->Create();
+ result r = __lock.Create();
SysTryLog(NID_BASE, !IsFailed(r), "Failed to create the mutex instance");
}
*/
int Register(void* pObject)
{
- result r = __pLock->Acquire();
+ result r = __lock.Acquire();
SysTryLog(NID_BASE, !IsFailed(r), "Failed to acquire mutex");
_Handle handle;
__pSlots[index].__pObject = pObject;
}
- r = __pLock->Release();
+ r = __lock.Release();
SysTryLog(NID_BASE, !IsFailed(r), "Failed to release mutex");
return handle.__handle;
*/
void* Unregister(unsigned int handle)
{
- result r = __pLock->Acquire();
+ result r = __lock.Acquire();
SysTryLog(NID_BASE, !IsFailed(r), "Failed to acquire mutex");
void* pObject = null;
if (index >= __slotCount)
{
- r = __pLock->Release();
+ r = __lock.Release();
SysTryLog(NID_BASE, !IsFailed(r), "Failed to release mutex");
SetLastResult(E_OBJ_NOT_FOUND);
_HandleElement& element = __pSlots[index];
if (element.__id != ((_Handle*)&handle)->__id)
{
- r = __pLock->Release();
+ r = __lock.Release();
SysTryLog(NID_BASE, !IsFailed(r), "Failed to release mutex");
SetLastResult(E_OBJ_NOT_FOUND);
__freeSlots.Add(index);
- r = __pLock->Release();
+ r = __lock.Release();
SysTryLog(NID_BASE, !IsFailed(r), "Failed to release mutex");
return pObject;
*/
const void* GetObject(unsigned int handle) const
{
- result r = __pLock->Acquire();
+ result r = __lock.Acquire();
SysTryLog(NID_BASE, !IsFailed(r), "Failed to acquire mutex");
const unsigned int index = ((_Handle*)&handle)->__index;
if (index >= __slotCount)
{
- r = __pLock->Release();
+ r = __lock.Release();
SysTryLog(NID_BASE, !IsFailed(r), "Failed to release mutex");
SetLastResult(E_OBJ_NOT_FOUND);
const _HandleElement& element = __pSlots[index];
if (element.__id != ((_Handle*)&handle)->__id)
{
- r = __pLock->Release();
+ r = __lock.Release();
SysTryLog(NID_BASE, !IsFailed(r), "Failed to release mutex");
SetLastResult(E_OBJ_NOT_FOUND);
return null;
}
- r = __pLock->Release();
+ r = __lock.Release();
SysTryLog(NID_BASE, !IsFailed(r), "Failed to release mutex");
return element.__pObject;
*/
int GetObjectCount(void) const
{
- result r = __pLock->Acquire();
+ result r = __lock.Acquire();
SysTryLog(NID_BASE, !IsFailed(r), "Failed to acquire mutex");
int cnt = static_cast <int>(__slotCount - __freeSlots.GetCount());
- r = __pLock->Release();
+ r = __lock.Release();
SysTryLog(NID_BASE, !IsFailed(r), "Failed to release mutex");
return cnt;
unsigned int __slotCount;
unsigned int __slotCapacity;
Tizen::Base::Collection::LinkedListT<unsigned int> __freeSlots;
- Tizen::Base::Runtime::Mutex* __pLock;
+ mutable Tizen::Base::Runtime::Mutex __lock;
};
}} // Tizen::Base