00001 #include "InlineFunctor.h" 00002 00003 void InlineFunctor::HandleResult(bool wasCancelled, void *context) 00004 { 00005 (void) wasCancelled; 00006 (void) context; 00007 ifp->Pop(callDepth); 00008 } 00009 00010 InlineFunctorProcessor::InlineFunctorProcessor() 00011 { 00012 00013 } 00014 InlineFunctorProcessor::~InlineFunctorProcessor() 00015 { 00016 StopThreads(false); 00017 } 00018 00019 void InlineFunctorProcessor::StartThreads(int numThreads) 00020 { 00021 functionThread.StartThreads(numThreads); 00022 } 00023 void InlineFunctorProcessor::StopThreads(bool blockOnCurrentProcessing) 00024 { 00025 functionThread.StopThreads(blockOnCurrentProcessing); 00026 } 00027 void InlineFunctorProcessor::YieldOnFunctor(InlineFunctor *inlineFunctor) 00028 { 00029 inlineFunctor->callDepth=GetCallDepth(); 00030 inlineFunctor->ifp=this; 00031 functionThread.Push(inlineFunctor); 00032 completedThreads.Push(false, __FILE__, __LINE__); 00033 } 00034 bool InlineFunctorProcessor::UpdateIFP(void) 00035 { 00036 functionThread.CallResultHandlers(); 00037 if (completedThreads.Size() && completedThreads[completedThreads.Size()-1]==true) 00038 { 00039 completedThreads.Pop(); 00040 return true; 00041 } 00042 return false; 00043 } 00044 void InlineFunctorProcessor::Pop(int threadCallDepth) 00045 { 00046 completedThreads[threadCallDepth]=true; 00047 } 00048 unsigned InlineFunctorProcessor::GetCallDepth(void) const 00049 { 00050 return completedThreads.Size(); 00051 }