mirror of
https://bitbucket.org/theswgsource/src-1.2.git
synced 2026-07-28 23:16:15 -04:00
Added sharedSynchronization library
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// Gate.cpp
|
||||
// Acy Stapp
|
||||
//
|
||||
// Copyright 6/19/2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "sharedSynchronization/Gate.h"
|
||||
|
||||
Gate::Gate(bool open)
|
||||
: cond(lock)
|
||||
{
|
||||
opened = open;
|
||||
}
|
||||
|
||||
Gate::~Gate()
|
||||
{
|
||||
}
|
||||
|
||||
void Gate::wait()
|
||||
{
|
||||
lock.enter();
|
||||
while (!opened)
|
||||
cond.wait();
|
||||
lock.leave();
|
||||
}
|
||||
|
||||
void Gate::close()
|
||||
{
|
||||
lock.enter();
|
||||
opened = false;
|
||||
lock.leave();
|
||||
}
|
||||
|
||||
void Gate::open()
|
||||
{
|
||||
lock.enter();
|
||||
opened = true;
|
||||
cond.broadcast();
|
||||
lock.leave();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user