24#ifndef _ODRXTHREADPOOLSERVICE_INCLUDED_
25#define _ODRXTHREADPOOLSERVICE_INCLUDED_
69 virtual void wait(
bool bNoThrow =
false) = 0;
74 virtual unsigned int getId()
const = 0;
538 return getMainThreadId() == getCurrentThreadId();
705 for(
int i=0; i<n; ++i ) {
726 return next( threadIndex, itemIndex );
736 OdMutex* mutex = mutexForNext();
738 while(
void* pItem = sync_next( mutex, (
OdUInt32)threadIndex, itemIndex ) ) {
739 doAction( (
OdUInt32)threadIndex, itemIndex, pItem );
761template<
class It,
class Fn >
767 bool next( It& cur ) {
769 if ( m_cur < m_last ) {
783 while( next( cur ) );
788 unsigned long n = last-first;
789 if( pQueue && n>1 ) {
795 n = ( n < numCPUs ) ? n : numCPUs;
802 std::for_each( first, last, fn );
809template<
class It,
class Fn >
820template<
class TObject >
832template<
class TObject,
class TInitFn = OdApcObjectPoolHelperDummyInitFn<TObject> >
845 m_pEntries = ::new TObject[n];
848 TObject& obj = m_pEntries[ n ];
857 m_pEntries = ::new TObject[1];
859 (*pInitFn)( *m_pEntries );
866 return static_cast<TObject*
>(
get()->take().get() );
877 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
TObject & at(OdUInt32 i) const
void init(OdRxThreadPoolService *pTP, int n=0, const TInitFn *pInitFn=0)
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)
OdApcQueueHelper & operator=(const OdApcQueueHelper &)=default
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 OdApcQueueHelper &)=default
OdApcQueueHelper(const OdApcQueue *pObject, OdRxObjMod m)
void setAtomPoolRef(OdApcObjectPool *pAtomPool)
OdApcQueueHelper(const OdBaseObjectPtr &pObject)
OdApcQueueHelper(const OdRxObjectPtr &pObject)
OdApcQueueHelper(const OdSmartPtr< OdApcQueue > &pObject)
OdApcQueueHelper(OdApcQueueHelper &&)=default
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 int numThreads() const =0
virtual void asyncProcCall(OdApcEntryPointRxObjParam ep, OdRxObject *parameter)=0
virtual void processException(bool bReThrow=true, bool bClear=true)=0
virtual unsigned int getId() const =0
virtual bool hasException() const =0
virtual void asyncProcCall(OdApcEntryPointVoidParam ep, OdApcParamType parameter)=0
virtual void wait(bool bNoThrow=false)=0
OdArray & setAt(size_type arrayIndex, const OdApcQueueHelper &value)
typename A::size_type size_type
OdApcQueueHelper & at(size_type arrayIndex)
void resize(size_type logicalLength, const OdApcQueueHelper &value)
virtual void apcEntryPoint(OdApcParamType threadIndex)
virtual void * next(OdUInt32 threadIndex, OdUInt32 &itemIndex)=0
virtual OdMutex * mutexForNext()=0
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 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 OdApcQueuePtr newSTQueue(unsigned nThreadAttributes=ThreadsCounter::kNoAttributes, OdUInt32 nFlags=kStQueueNoFlags)=0
virtual OdApcEventPtr newEvent()=0
virtual OdApcQueuePtr newMTQueue(unsigned nThreadAttributes=ThreadsCounter::kNoAttributes, int numThreads=0, OdUInt32 nFlags=kMtQueueNoFlags)=0
bool isMainThread() const
virtual void unregisterExternalThreads(unsigned nThreads, const unsigned *aThreads)=0
virtual unsigned int getCurrentThreadId() const =0
virtual ExecuteMainThreadFunc getExternalMainThreadFunc() const =0
virtual unsigned int getMainThreadId() const =0
virtual int numPhysicalCores() const =0
virtual OdApcGatewayPtr newGateway()=0
typedef void(APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture)
void operator()(TObject &) const