90 lines
1.1 KiB
C++
90 lines
1.1 KiB
C++
/*
|
|
ZSema.hpp
|
|
Author: James Russell <jcrussell@762studios.com>
|
|
|
|
Purpose: RAII wrapper for libsst-concurrency SST_Semaphore.
|
|
|
|
Changelog
|
|
2011/11/27 - creation (jcrussell)
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#ifndef _ZSEMAPHORE_H
|
|
#define _ZSEMAPHORE_H
|
|
|
|
#include <ZUtil/ZUtilBuild.hpp>
|
|
|
|
#include <SST/SST_Semaphore.h>
|
|
|
|
/*
|
|
ZSemaphore class. Used to allocate and deallocate a semaphore within the scope of a class.
|
|
Cannot be copied or assigned, which prevents it from being used in stl-like containers.
|
|
*/
|
|
class ZSemaphore
|
|
{
|
|
private:
|
|
DISABLE_COPY_AND_ASSIGN(ZSemaphore);
|
|
|
|
//libsst Semaphore
|
|
SST_Semaphore Semaphore;
|
|
|
|
public:
|
|
/*
|
|
Constructor.
|
|
|
|
@param _initialCount - initial count of the semaphore
|
|
*/
|
|
ZSemaphore(int _initialCount);
|
|
|
|
/*
|
|
Destructor.
|
|
*/
|
|
~ZSemaphore();
|
|
|
|
/*
|
|
public ZSema::Post
|
|
|
|
TODO
|
|
|
|
@return (void)
|
|
@context (all)
|
|
*/
|
|
void Post();
|
|
|
|
/*
|
|
public ZSema::Post
|
|
|
|
TODO
|
|
|
|
@param _count -
|
|
@return (void)
|
|
@context (all)
|
|
*/
|
|
void Post(uint32_t _count);
|
|
|
|
/*
|
|
public ZSema::Wait
|
|
|
|
TODO
|
|
|
|
@return (bool)
|
|
@context (all)
|
|
*/
|
|
bool Wait();
|
|
|
|
/*
|
|
public ZSema::Wait
|
|
|
|
TODO
|
|
|
|
@param _ms -
|
|
@return (bool)
|
|
@context (all)
|
|
*/
|
|
bool Wait(uint32_t _ms);
|
|
};
|
|
|
|
#endif
|
|
|