namespace Tizen { namespace Social
{
-__thread bool isAccountDbConnected = false;
-pthread_key_t accountTlsKey = 0;
+bool _AccountDbConnector::__isAccountDbConnected = false;
_AccountDbConnector* _AccountDbConnector::__pInstance = null;
_AccountDbConnector::_AccountDbConnector(void)
{
}
-void
-_AccountDbConnector::OnThreadExit(void *pValue)
-{
- _AccountDbConnector* pInstance = static_cast<_AccountDbConnector*>(pValue);
-
- if (pInstance != null)
- {
- pInstance->Disconnect();
- }
-
- pthread_setspecific(accountTlsKey, null);
-}
-
result
_AccountDbConnector::Connect(void)
{
int ret = account_connect();
SysTryReturnResult(NID_SCL, ret == ACCOUNT_ERROR_NONE, E_SYSTEM, "The method cannot proceed due to a severe system error.");
- pthread_setspecific(accountTlsKey, this);
-
return E_SUCCESS;
}
result
_AccountDbConnector::EnsureDbConnection(void)
{
- if (!isAccountDbConnected)
+ if (!__isAccountDbConnected)
{
_AccountDbConnector* 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));
- isAccountDbConnected = true;
+ __isAccountDbConnected = true;
}
return E_SUCCESS;
__pInstance = pInstance.release();
- pthread_key_create(&accountTlsKey, OnThreadExit);
-
std::atexit(DestroyAccountDbConnector);
}