mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-10 10:18:21 +00:00
0545adfac3
Have fun!
50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
#include "InlineFunctor.h"
|
|
|
|
void InlineFunctor::HandleResult(bool wasCancelled, void *context)
|
|
{
|
|
ifp->Pop(callDepth);
|
|
}
|
|
|
|
InlineFunctorProcessor::InlineFunctorProcessor()
|
|
{
|
|
|
|
}
|
|
InlineFunctorProcessor::~InlineFunctorProcessor()
|
|
{
|
|
StopThreads(false);
|
|
}
|
|
|
|
void InlineFunctorProcessor::StartThreads(int numThreads)
|
|
{
|
|
functionThread.StartThreads(numThreads);
|
|
}
|
|
void InlineFunctorProcessor::StopThreads(bool blockOnCurrentProcessing)
|
|
{
|
|
functionThread.StopThreads(blockOnCurrentProcessing);
|
|
}
|
|
void InlineFunctorProcessor::YieldOnFunctor(InlineFunctor *inlineFunctor)
|
|
{
|
|
inlineFunctor->callDepth=GetCallDepth();
|
|
inlineFunctor->ifp=this;
|
|
functionThread.Push(inlineFunctor);
|
|
completedThreads.Push(false);
|
|
}
|
|
bool InlineFunctorProcessor::UpdateIFP(void)
|
|
{
|
|
functionThread.CallResultHandlers();
|
|
if (completedThreads.Size() && completedThreads[completedThreads.Size()-1]==true)
|
|
{
|
|
completedThreads.Pop();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
void InlineFunctorProcessor::Pop(int threadCallDepth)
|
|
{
|
|
completedThreads[threadCallDepth]=true;
|
|
}
|
|
unsigned InlineFunctorProcessor::GetCallDepth(void) const
|
|
{
|
|
return completedThreads.Size();
|
|
}
|