namespace Tizen { namespace Social
{
-__thread bool isConnected = false;
-pthread_key_t tlsKey = 0;
+bool _ContactDbConnector::__isConnected = false;
_ContactDbConnector* _ContactDbConnector::__pInstance = null;
_ContactDbConnector::_ContactDbConnector(void)
{
}
-void
-_ContactDbConnector::OnThreadExit(void *pValue)
-{
- _ContactDbConnector* pInstance = static_cast<_ContactDbConnector*>(pValue);
-
- if (pInstance != null)
- {
- pInstance->Disconnect();
- }
-
- pthread_setspecific(tlsKey, NULL);
-}
-
result
_ContactDbConnector::Connect(void)
{
SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_IPC_NOT_AVALIABLE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. Contact server is not available. Elapsed time : %lld", GetErrorMessage(E_SYSTEM), endTicks - startTicks);
SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
- pthread_setspecific(tlsKey, this);
-
return E_SUCCESS;
}
result
_ContactDbConnector::EnsureDbConnection(void)
{
- if (!isConnected)
+ if (!__isConnected)
{
_ContactDbConnector* pInstance = GetInstance();
SysTryReturn(NID_SCL, pInstance != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
result r = pInstance->Connect();
SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
- isConnected = true;
+ __isConnected = true;
}
return E_SUCCESS;
__pInstance = pInstance.release();
- pthread_key_create(&tlsKey, OnThreadExit);
-
std::atexit(DestroyContactDbConnector);
}