87 lines
1.5 KiB
C++
87 lines
1.5 KiB
C++
/*
|
|
ZEvent.hpp
|
|
Author: James Russell <jcrussell@762studios.com>
|
|
|
|
Purpose: RAII wrapper for SST_Event from libsst-concurrency.
|
|
|
|
Changelog
|
|
2011/11/27 - creation (jcrussell)
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#ifndef _ZEVENT_H
|
|
#define _ZEVENT_H
|
|
|
|
#include <ZUtil/ZUtilBuild.hpp>
|
|
#include <SST/SST_Event.h>
|
|
|
|
/*
|
|
Event class. Used to manage allocation and deallocation of events.
|
|
Cannot be copied or assigned, which prevents it from being used in stl-like containers.
|
|
*/
|
|
class ZEvent
|
|
{
|
|
private:
|
|
DISABLE_COPY_AND_ASSIGN(ZEvent);
|
|
|
|
//libsst Event
|
|
SST_Event Event;
|
|
|
|
public:
|
|
/*
|
|
Constructor. Creates an event from libsst-concurrency.
|
|
*/
|
|
ZEvent();
|
|
|
|
/*
|
|
Destructor. Frees our event from libsst-concurrency.
|
|
*/
|
|
~ZEvent();
|
|
|
|
/*
|
|
public ZSignal::Notify
|
|
|
|
Signals event, waking up all waiting threads. Until this event is reset, waiting threads will return.
|
|
|
|
@return (void)
|
|
@context (all)
|
|
*/
|
|
void Notify();
|
|
|
|
/*
|
|
public ZSignal::Reset
|
|
|
|
Signals reset, which causes threads that call Wait to block until signaled.
|
|
|
|
@return (void)
|
|
@context (all)
|
|
*/
|
|
void Reset();
|
|
|
|
/*
|
|
public ZSignal::Wait
|
|
|
|
Waits on a signal. Blocks until Signal is called.
|
|
|
|
@return (bool) - true if the event was signaled, false if returned before a signal (such as event not reset)
|
|
@context (all)
|
|
*/
|
|
bool Wait();
|
|
|
|
/*
|
|
public ZSignal::Wait
|
|
|
|
Waits on a signal for an amount of time.
|
|
|
|
@param _ms - the amount of time (in ms) to wait.
|
|
@return (bool) - true if the event was signaled, false if returned before a signal (event not reset our out of time).
|
|
@context (all)
|
|
*/
|
|
bool Wait(uint32_t _ms);
|
|
};
|
|
|
|
|
|
#endif
|
|
|