PhysicsFS 2.0.3 imported.
This commit is contained in:
parent
bcc0937726
commit
993311d151
459 changed files with 87785 additions and 0 deletions
45
lib/physfs-2.0.3/lzma/CPP/7zip/Common/VirtThread.cpp
Normal file
45
lib/physfs-2.0.3/lzma/CPP/7zip/Common/VirtThread.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
// VirtThread.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "VirtThread.h"
|
||||
|
||||
static THREAD_FUNC_DECL CoderThread(void *p)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
CVirtThread *t = (CVirtThread *)p;
|
||||
t->StartEvent.Lock();
|
||||
if (t->ExitEvent)
|
||||
return 0;
|
||||
t->Execute();
|
||||
t->FinishedEvent.Set();
|
||||
}
|
||||
}
|
||||
|
||||
HRes CVirtThread::Create()
|
||||
{
|
||||
RINOK(StartEvent.CreateIfNotCreated());
|
||||
RINOK(FinishedEvent.CreateIfNotCreated());
|
||||
StartEvent.Reset();
|
||||
FinishedEvent.Reset();
|
||||
ExitEvent = false;
|
||||
if (Thread.IsCreated())
|
||||
return S_OK;
|
||||
return Thread.Create(CoderThread, this);
|
||||
}
|
||||
|
||||
void CVirtThread::Start()
|
||||
{
|
||||
ExitEvent = false;
|
||||
StartEvent.Set();
|
||||
}
|
||||
|
||||
CVirtThread::~CVirtThread()
|
||||
{
|
||||
ExitEvent = true;
|
||||
if (StartEvent.IsCreated())
|
||||
StartEvent.Set();
|
||||
Thread.Wait();
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue