本文整理汇总了C++中Handle::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::GetType方法的具体用法?C++ Handle::GetType怎么用?C++ Handle::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Handle
的用法示例。
在下文中一共展示了Handle::GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fkt_begin_critical
static Symbol* fkt_begin_critical(const std::vector<Symbol*>& vecSyms,
ParseInfo& info, RuntimeInfo &runinfo, SymbolTable* pSymTab)
{
// no argument given: lock global mutex
if(vecSyms.size() == 0)
{
info.pmutexGlobal->lock();
}
else
{
for(Symbol* pSym : vecSyms)
{
if(pSym->GetType() == SYMBOL_ARRAY)
fkt_begin_critical(((SymbolArray*)pSym)->GetArr(), info, runinfo, pSymTab);
else if(pSym->GetType() == SYMBOL_INT)
{
//std::lock_guard<std::mutex> lck(*info.pmutexCrit);
int iHandle = pSym->GetValInt();
Handle *pHandle = info.phandles->GetHandle(iHandle);
if(pHandle==0 || pHandle->GetType()!=HANDLE_MUTEX)
{
std::ostringstream ostrErr;
ostrErr << linenr(runinfo) << "Handle ("
<< iHandle << ") does not exist"
<< " or is not a mutex handle. Ignoring."
<< std::endl;
throw tl::Err(ostrErr.str(), 0);
//continue;
}
std::mutex *pMutex = ((HandleMutex*)pHandle)->GetInternalHandle();
pMutex->lock();
}
else
{
std::ostringstream ostrErr;
ostrErr << linenr(runinfo) << "Invalid mutex handle: "
<< pSym->print() << " Ignoring." << std::endl;
throw tl::Err(ostrErr.str(), 0);
}
}
}
return 0;
}
示例2: fkt_thread_join
static Symbol* fkt_thread_join(const std::vector<Symbol*>& vecSyms,
ParseInfo& info, RuntimeInfo &runinfo, SymbolTable* pSymTab)
{
if(vecSyms.size()<1)
{
std::ostringstream ostrErr;
ostrErr << linenr(runinfo) << "join needs at least one argument." << std::endl;
throw tl::Err(ostrErr.str(),0);
}
Symbol *pRet = 0;
for(Symbol* pSym : vecSyms)
{
if(pSym == 0) continue;
if(pSym->GetType() == SYMBOL_ARRAY)
{
return fkt_thread_join(((SymbolArray*)pSym)->GetArr(), info, runinfo, pSymTab);
}
if(pSym->GetType() != SYMBOL_INT)
{
std::ostringstream ostrErr;
ostrErr << linenr(runinfo) << "join needs thread handles." << std::endl;
throw tl::Err(ostrErr.str(), 0);
//continue;
}
t_int iHandle = ((SymbolInt*)pSym)->GetVal();
Handle *pHandle = info.phandles->GetHandle(iHandle);
if(pHandle==0)
{
std::ostringstream ostrErr;
ostrErr << linenr(runinfo) << "Handle ("
<< iHandle << ") does not exist." << std::endl;
throw tl::Err(ostrErr.str(), 0);
//continue;
}
if(pHandle->GetType() == HANDLE_THREAD)
{
HandleThread *pThreadHandle = (HandleThread*)pHandle;
std::thread *pThread = pThreadHandle->GetInternalHandle();
//log_debug("Joining thread ", pThread, "...");
pThread->join();
//log_debug("Joined thread ", pThread, ".");
}
else if(pHandle->GetType() == HANDLE_TASK)
{
HandleTask *pTaskHandle = (HandleTask*)pHandle;
std::future<Symbol*> *pFut = pTaskHandle->GetInternalHandle();
// TODO: array task joins
if(pRet != 0)
delete pRet;
pRet = pFut->get();
}
else
{
std::ostringstream ostrErr;
ostrErr << linenr(runinfo) << "Handle ("
<< iHandle << ") is invalid." << std::endl;
throw tl::Err(ostrErr.str(), 0);
}
info.phandles->CloseHandle(iHandle);
}
return pRet;
}