102 else if (size <
Tail)
158 Destruct<ThreadCommand>(toCommand());
160 memcpy(Buffer, (
void*)cmd, Size);
169 GetEvent()->PulseEvent();
182 : pQueue(queue), ExitEnqueued(false), ExitProcessed(false), CommandBuffer(2048)
203 pImpl->ExitProcessed =
true;
206 {
return Construct<ExitCommand>(p, *
this); }
214 if (!AvailableEvents.IsNull(p))
223 AvailableEvents.PushBack(p);
228 while(!AvailableEvents.IsEmpty())
251 FreeNotifyEvents_NTS();
265 if (queueAvailableEvent)
267 FreeNotifyEvent_NTS(queueAvailableEvent);
268 queueAvailableEvent = 0;
272 if (ExitEnqueued && !command.
ExitFlag)
276 bool bufferWasEmpty = CommandBuffer.IsEmpty();
282 completeEvent = c->
pEvent = AllocNotifyEvent_NTS();
285 pQueue->OnPushNonEmpty_Locked();
289 queueAvailableEvent = AllocNotifyEvent_NTS();
290 BlockedProducers.PushBack(queueAvailableEvent);
293 queueAvailableEvent->
Wait();
300 completeEvent->
Wait();
302 FreeNotifyEvent_NTS(completeEvent);
314 UByte* buffer = CommandBuffer.ReadBegin();
318 pQueue->OnPopEmpty_Locked();
323 CommandBuffer.ReadEnd(popBuffer->
GetSize());
325 if (!BlockedProducers.IsEmpty())
349 return pImpl->PushCommand(command);
354 return pImpl->PopCommand(popBuffer);
366 if (pImpl->ExitEnqueued)
368 pImpl->ExitEnqueued =
true;
376 return pImpl->ExitProcessed;
#define OVR_FREE_ALIGNED(p)
CircularBuffer CommandBuffer
virtual void Execute() const
virtual ~ThreadCommandQueue()
ExitCommand(ThreadCommandQueueImpl *impl, bool wait)
#define OVR_ALLOC_ALIGNED(s, a)
__BEGIN_NAMESPACE_STD void * memcpy(void *__restrict __dest, const void *__restrict __src, size_t __n) __THROW __nonnull((1
virtual void Execute() const =0
~ThreadCommandQueueImpl()
void FreeNotifyEvent_NTS(NotifyEvent *p)
bool PushCommand(const ThreadCommand &command)
void PushExitCommand(bool wait)
ThreadCommandQueueImpl(ThreadCommandQueue *queue)
bool PopCommand(ThreadCommand::PopBuffer *popBuffer)
void InitFromBuffer(void *data)
ThreadCommandQueue * pQueue
UByte * Write(UPInt size)
CircularBuffer(UPInt size)
ThreadCommandQueueImpl * pImpl
virtual ThreadCommand * CopyConstruct(void *p) const
bool PushCommand(const ThreadCommand &command)
ThreadCommand::NotifyEvent NotifyEvent
volatile bool ExitEnqueued
List< NotifyEvent > BlockedProducers
volatile bool ExitProcessed
void FreeNotifyEvents_NTS()
List< NotifyEvent > AvailableEvents
ThreadCommand * toCommand() const
bool PopCommand(ThreadCommand::PopBuffer *popBuffer)
UPInt roundUpSize(UPInt size)
NotifyEvent * AllocNotifyEvent_NTS()
virtual ThreadCommand * CopyConstruct(void *p) const =0