#include <FBaseObject.h>
#include <FBaseColLinkedListT.h>
+#include <FBaseRtMutex.h>
+#include <FBaseSysLog.h>
namespace Tizen { namespace Base
{
__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();
+ SysTryLog(NID_BASE, !IsFailed(r), "Failed to create the mutex instance");
}
/**
virtual ~_ObjectManagerImpl(void)
{
delete[] __pSlots;
+ delete __pLock;
}
/**
{
__pSlots[i] = pObjectManagerImpl.__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();
+ SysTryLog(NID_BASE, !IsFailed(r), "Failed to create the mutex instance");
}
/**
*/
int Register(void* pObject)
{
+ result r = __pLock->Acquire();
+ SysTryLog(NID_BASE, !IsFailed(r), "Failed to acquire mutex");
+
_Handle handle;
if (__freeSlots.GetCount() == 0)
__pSlots[index].__pObject = pObject;
}
+ r = __pLock->Release();
+ SysTryLog(NID_BASE, !IsFailed(r), "Failed to release mutex");
+
return handle.__handle;
}
*/
void* Unregister(unsigned int handle)
{
+ result r = __pLock->Acquire();
+ SysTryLog(NID_BASE, !IsFailed(r), "Failed to acquire mutex");
+
void* pObject = null;
const unsigned int index = ((_Handle*)&handle)->__index;
__freeSlots.Add(index);
+ r = __pLock->Release();
+ SysTryLog(NID_BASE, !IsFailed(r), "Failed to release mutex");
+
return pObject;
}
*/
const void* GetObject(unsigned int handle) const
{
+ result r = __pLock->Acquire();
+ SysTryLog(NID_BASE, !IsFailed(r), "Failed to acquire mutex");
+
const unsigned int index = ((_Handle*)&handle)->__index;
if (index >= __slotCount)
return null;
}
+ r = __pLock->Release();
+ SysTryLog(NID_BASE, !IsFailed(r), "Failed to release mutex");
+
return element.__pObject;
}
*/
int GetObjectCount(void) const
{
- return static_cast <int>(__slotCount - __freeSlots.GetCount());
+ result r = __pLock->Acquire();
+ SysTryLog(NID_BASE, !IsFailed(r), "Failed to acquire mutex");
+
+ int cnt = static_cast <int>(__slotCount - __freeSlots.GetCount());
+
+ r = __pLock->Release();
+ SysTryLog(NID_BASE, !IsFailed(r), "Failed to release mutex");
+
+ return cnt;
}
bool IsValidHandle(unsigned int handle) const
unsigned int __slotCount;
unsigned int __slotCapacity;
Tizen::Base::Collection::LinkedListT<unsigned int> __freeSlots;
+ Tizen::Base::Runtime::Mutex* __pLock;
};