void MtCoder_Destruct(CMtCoder* p) { unsigned i; for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++) CMtThread_Destruct(&p->threads[i]); CriticalSection_Delete(&p->cs); CriticalSection_Delete(&p->mtProgress.cs); }
void MtSync_Destruct(CMtSync *p) { if (Thread_WasCreated(&p->thread)) { MtSync_StopWriting(p); p->exit = True; if (p->needStart) Event_Set(&p->canStart); Thread_Wait(&p->thread); Thread_Close(&p->thread); } if (p->csWasInitialized) { CriticalSection_Delete(&p->cs); p->csWasInitialized = False; } Event_Close(&p->canStart); Event_Close(&p->wasStarted); Event_Close(&p->wasStopped); Semaphore_Close(&p->freeSemaphore); Semaphore_Close(&p->filledSemaphore); p->wasCreated = False; }