本文整理汇总了C++中xbmcthreads::ThreadLocal类的典型用法代码示例。如果您正苦于以下问题:C++ ThreadLocal类的具体用法?C++ ThreadLocal怎么用?C++ ThreadLocal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ThreadLocal类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setLanguageHook
namespace XBMCAddon
{
// just need a place for the vtab
LanguageHook::~LanguageHook() {}
static XbmcThreads::ThreadLocal<LanguageHook> addonLanguageHookTls;
static bool threadLocalInitilialized = false;
static xbmcutil::InitFlag initer(threadLocalInitilialized);
void LanguageHook::setLanguageHook(LanguageHook* languageHook)
{
TRACE;
languageHook->Acquire();
addonLanguageHookTls.set(languageHook);
}
LanguageHook* LanguageHook::getLanguageHook()
{
return threadLocalInitilialized ? addonLanguageHookTls.get() : NULL;
}
void LanguageHook::clearLanguageHook()
{
LanguageHook* lh = addonLanguageHookTls.get();
addonLanguageHookTls.set(NULL);
if (lh)
lh->Release();
}
}
示例2: guiLock
namespace XBMCAddonUtils
{
//***********************************************************
// Some simple helpers
void guiLock()
{
g_graphicsContext.Lock();
}
void guiUnlock()
{
g_graphicsContext.Unlock();
}
//***********************************************************
static char defaultImage[1024];
const char *getDefaultImage(char* cControlType, char* cTextureType, char* cDefault)
{
// create an xml block so that we can resolve our defaults
// <control type="type">
// <description />
// </control>
TiXmlElement control("control");
control.SetAttribute("type", cControlType);
TiXmlElement filler("description");
control.InsertEndChild(filler);
g_SkinInfo->ResolveIncludes(&control);
// ok, now check for our texture type
TiXmlElement *pTexture = control.FirstChildElement(cTextureType);
if (pTexture)
{
// found our textureType
TiXmlNode *pNode = pTexture->FirstChild();
if (pNode && pNode->Value()[0] != '-')
{
strncpy(defaultImage, pNode->Value(), sizeof(defaultImage));
defaultImage[sizeof(defaultImage) - 1] = '\0';
return defaultImage;
}
}
return cDefault;
}
#ifdef ENABLE_XBMC_TRACE_API
static XbmcThreads::ThreadLocal<TraceGuard> tlParent;
static char** getSpacesArray(int size)
{
char** ret = new char*[size];
for (int i = 0; i < size; i++)
{
ret[i] = new char[i + 1];
int j;
for (j = 0; j < i; j++)
ret[i][j] = ' ';
ret[i][j] = 0;
}
return ret;
}
static char** spaces = getSpacesArray(256);
const char* TraceGuard::getSpaces() { return spaces[depth]; }
TraceGuard::TraceGuard(const char* _function) :function(_function)
{
parent = tlParent.get();
depth = parent == NULL ? 0 : parent->depth + 1;
tlParent.set(this);
CLog::Log(LOGDEBUG, "%sNEWADDON Entering %s", spaces[depth], function);
}
TraceGuard::TraceGuard() :function(NULL)
{
parent = tlParent.get();
depth = parent == NULL ? 0 : parent->depth + 1;
tlParent.set(this);
// silent
}
TraceGuard::~TraceGuard()
{
if (function)
CLog::Log(LOGDEBUG, "%sNEWADDON Leaving %s", spaces[depth], function);
// need to pop the stack
tlParent.set(this->parent);
}
#endif
}
示例3: clearLanguageHook
void LanguageHook::clearLanguageHook()
{
LanguageHook* lh = addonLanguageHookTls.get();
addonLanguageHookTls.set(NULL);
if (lh)
lh->Release();
}
示例4:
TraceGuard::TraceGuard() :function(NULL)
{
parent = tlParent.get();
depth = parent == NULL ? 0 : parent->depth + 1;
tlParent.set(this);
// silent
}
示例5: staticThread
THREADFUNC CThread::staticThread(void* data)
{
CThread* pThread = (CThread*)(data);
std::string name;
ThreadIdentifier id;
bool autodelete;
if (!pThread) {
CLog::Log(LOGERROR,"%s, sanity failed. thread is NULL.",__FUNCTION__);
return 1;
}
name = pThread->m_ThreadName;
id = pThread->m_ThreadId;
autodelete = pThread->m_bAutoDelete;
pThread->SetThreadInfo();
CLog::Log(LOGNOTICE,"Thread %s start, auto delete: %s", name.c_str(), (autodelete ? "true" : "false"));
currentThread.set(pThread);
pThread->m_StartEvent.Set();
pThread->OnStartup();
pThread->Process();
pThread->OnExit();
// lock during termination
CSingleLock lock(pThread->m_CriticalSection);
pThread->m_ThreadId = 0;
pThread->m_TermEvent.Set();
pThread->TermHandler();
lock.Leave();
if (autodelete)
{
CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", name.c_str(), (uint64_t)id);
delete pThread;
pThread = NULL;
}
else
CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating", name.c_str(), (uint64_t)id);
return 0;
}
示例6: GetCurrentThread
CThread* CThread::GetCurrentThread()
{
return currentThread.get();
}
示例7: getLanguageHook
LanguageHook* LanguageHook::getLanguageHook()
{
return threadLocalInitilialized ? addonLanguageHookTls.get() : NULL;
}