24 #ifndef _ODRXTHREADPOOLSERVICE_INCLUDED_
25 #define _ODRXTHREADPOOLSERVICE_INCLUDED_
73 virtual unsigned int getId()
const = 0;
647 for(
int i=0; i<n; ++i ) {
668 return next( threadIndex, itemIndex );
678 OdMutex* mutex = mutexForNext();
680 while(
void* pItem = sync_next( mutex, (
OdUInt32)threadIndex, itemIndex ) ) {
681 doAction( (
OdUInt32)threadIndex, itemIndex, pItem );
703 template<
class It,
class Fn >
709 bool next( It& cur ) {
711 if ( m_cur < m_last ) {
725 while( next( cur ) );
730 unsigned long n = last-first;
731 if( pQueue && n>1 ) {
737 n = ( n < numCPUs ) ? n : numCPUs;
744 std::for_each( first, last, fn );
750 template<
class It,
class Fn >
759 template<
class TObject >
768 template<
class TObject,
class TInitFn = OdApcObjectPoolHelperDummyInitFn<TObject> >
781 m_pEntries = ::new TObject[n];
784 TObject& obj = m_pEntries[ n ];
793 m_pEntries = ::new TObject[1];
795 (*pInitFn)( *m_pEntries );
802 return static_cast<TObject*
>(
get()->take().get() );
813 return m_pEntries[i];
#define ODA_ASSERT_ONCE(exp)
OdSmartPtr< OdApcGateway > OdApcGatewayPtr
OdSmartPtr< OdRxThreadPoolService > OdRxThreadPoolServicePtr
void(* OdApcEntryPointVoidParam)(OdApcParamType parameter)
@ kMtQueueAllowExecByMain
@ kMtQueueForceNewThreads
OdSmartPtr< OdApcLoopedGateway > OdApcLoopedGatewayPtr
OdSmartPtr< OdApcObjectPool > OdApcObjectPoolPtr
void od_async_for_each(OdApcQueue *pQueue, It first, It last, Fn fn)
OdSmartPtr< OdApcEvent > OdApcEventPtr
OdSmartPtr< OdApcThread > OdApcThreadPtr
OdSmartPtr< OdApcDataReadWriteDispatcher > OdApcDataReadWriteDispatcherPtr
void(* OdApcEntryPointRxObjParam)(OdRxObject *parameter)
OdSmartPtr< OdApcAtom > OdApcAtomPtr
OdSmartPtr< OdApcQueue > OdApcQueuePtr
void(* ExecuteMainThreadFunc)(MainThreadFunc, void *)
void(* MainThreadFunc)(void *)
virtual void apcEntryPoint(OdRxObject *pMessage)
virtual void apcEntryPoint(OdApcParamType pMessage)
virtual void unlockFromInside()=0
virtual void lockFromInside()=0
virtual void waitAndReset()=0
virtual void passBySecondary()=0
virtual void unlockByMain()=0
virtual void waitByMain()=0
virtual void lockByMain(OdUInt32 numThreads)=0
virtual void passByMainNoWait()=0
virtual void init(OdUInt32 numThreads)=0
virtual void waitByMain()=0
virtual void passBySecondary()=0
virtual void passByMain()=0
void init(OdRxThreadPoolService *pTP, int n=0, const TInitFn *pInitFn=0)
TObject & at(OdUInt32 i) const
virtual void put(OdRxObject *pObj)=0
virtual void reserve(OdUInt32 n)=0
virtual OdRxObjectPtr take()=0
void initST(int n, OdRxThreadPoolService *pTP)
OdApcQueueHelper(OdRxObject *pObject, OdRxObjMod m)
void initST(OdRxThreadPoolService *pThreadPool)
OdApcQueueHelper(const OdRxObject *pObject)
void initMT(OdRxThreadPoolService *pThreadPool)
void call(OdApcAtom *pAction, OdApcParamType param)
void call(OdApcAtom *pAction, OdRxObject *pParam=0)
OdApcQueueHelper(const OdApcQueue *pObject, OdRxObjMod m)
void setAtomPoolRef(OdApcObjectPool *pAtomPool)
OdApcQueueHelper(const OdBaseObjectPtr &pObject)
OdApcQueueHelper(const OdRxObjectPtr &pObject)
OdApcQueueHelper(const OdSmartPtr< OdApcQueue > &pObject)
OdApcQueueHelper(const OdApcQueue *pObject)
virtual void addEntryPoint(OdApcAtom *pRecipient, OdRxObject *pMessage=0)=0
virtual void executeMainThreadAction(MainThreadFunc mtFunc, void *pArg)=0
virtual void addEntryPoint(OdApcAtom *pRecipient, OdApcParamType pMessage)=0
virtual void setAtomPoolRef(OdApcObjectPool *pAtomPool)=0
virtual OdRxThreadPoolService & framework()=0
virtual void asyncProcCall(OdApcEntryPointRxObjParam ep, OdRxObject *parameter)=0
virtual unsigned int getId() const =0
virtual void asyncProcCall(OdApcEntryPointVoidParam ep, OdApcParamType parameter)=0
OdArray & setAt(size_type arrayIndex, const OdApcQueueHelper &value)
OdApcQueueHelper & at(size_type arrayIndex)
void resize(size_type logicalLength, const OdApcQueueHelper &value)
virtual OdMutex * mutexForNext()=0
virtual void * next(OdUInt32 threadIndex, OdUInt32 &itemIndex)=0
virtual void apcEntryPoint(OdApcParamType threadIndex)
void for_each(OdApcQueue *pQueue, OdUInt32 nThreads=0)
virtual void doAction(OdUInt32 threadIndex, OdUInt32 itemIndex, void *pItem)=0
void for_each(OdApcQueue *pQueue, It first, It last, Fn fn)
virtual OdApcThreadPtr newThread()=0
virtual int numThreads() const =0
virtual OdApcLoopedGatewayPtr newLoopedGateway()=0
virtual int numFreeThreads() const =0
virtual OdApcQueuePtr newSTQueue()=0
virtual int numCPUs() const =0
virtual void externalThreadStop()=0
virtual void registerExternalThreads(unsigned nThreads, const unsigned *aThreads, unsigned nThreadAttribs=ThreadsCounter::kNoAttributes)=0
virtual OdApcObjectPoolPtr newObjectPool()=0
virtual void externalThreadStart()=0
ODRX_DECLARE_MEMBERS(OdRxThreadPoolService)
virtual void executeMainThreadAction(MainThreadFunc mtFunc, void *pArg)=0
virtual void setExternalMainThreadFunc(ExecuteMainThreadFunc execFunc)=0
virtual OdApcEventPtr newEvent()=0
virtual OdApcQueuePtr newMTQueue(unsigned nThreadAttributes=ThreadsCounter::kNoAttributes, int numThreads=0, OdUInt32 nFlags=kMtQueueNoFlags)=0
virtual void unregisterExternalThreads(unsigned nThreads, const unsigned *aThreads)=0
virtual ExecuteMainThreadFunc getExternalMainThreadFunc() const =0
virtual int numPhysicalCores() const =0
virtual OdApcGatewayPtr newGateway()=0
typedef void(APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture)
void operator()(TObject &) const