libnative-utilities/include/raknet/SignaledEvent.hpp
2024-08-15 18:40:30 +08:00

70 lines
1.0 KiB
C++

/*
* Copyright (c) 2014, Oculus VR, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#ifndef __SIGNALED_EVENT_H
#define __SIGNALED_EVENT_H
#if defined(_WIN32)
#include "WindowsIncludes.hpp"
#else
#include <pthread.hpp>
#include <sys/types.h>
#include "SimpleMutex.hpp"
#endif
#include "Export.hpp"
namespace RakNet
{
class RAK_DLL_EXPORT SignaledEvent
{
public:
SignaledEvent();
~SignaledEvent();
void InitEvent(void);
void CloseEvent(void);
void SetEvent(void);
void WaitOnEvent(int timeoutMs);
protected:
#ifdef _WIN32
HANDLE eventList;
#else
SimpleMutex isSignaledMutex;
bool isSignaled;
#if !defined(ANDROID)
pthread_condattr_t condAttr;
#endif
pthread_cond_t eventList;
pthread_mutex_t hMutex;
pthread_mutexattr_t mutexAttr;
#endif
};
} // namespace RakNet
#endif