Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
SemWaitableEvent.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Execution_Platform_POSIX_SemWaitableEvent_h_
5#define _Stroika_Foundation_Execution_Platform_POSIX_SemWaitableEvent_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <semaphore.h>
10
11#if !qStroika_Foundation_Common_Platform_POSIX
12#error "ONLY INCLUDE FOR POSIX"
13#endif
14
15/**
16 *
17 * TODO:
18 */
19
21
22 /**
23 * Very simplistic wrapper on sem_init/sem_wait/sem_post POSIX semaphore APIs.
24 *
25 * Useful because they work from signal handlers, when most other APIs don't.
26 */
28 public:
30 SemWaitableEvent (const SemWaitableEvent&) = delete;
31
32 public:
34
35 public:
36 /**
37 * @see http://pubs.opengroup.org/onlinepubs/7908799/xsh/sem_wait.html
38 */
39 nonvirtual void Wait ();
40
41 public:
42 /**
43 * @see http://pubs.opengroup.org/onlinepubs/7908799/xsh/sem_post.html
44 *
45 * \note this is SAFE to call from within a signal handler on POSIX.
46 */
47 nonvirtual void Set ();
48
49 private:
50#if qCompilerAndStdLib_unnamed_semaphores_Buggy
51 sem_t* fSem_;
52#else
53 sem_t fSem_;
54#endif
55 };
56
57}
58
59/*
60 ********************************************************************************
61 ***************************** Implementation Details ***************************
62 ********************************************************************************
63 */
64#include "SemWaitableEvent.inl"
65
66#endif /*_Stroika_Foundation_Execution_Platform_POSIX_SemWaitableEvent_h_*/