DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
Semaphore.h
Go to the documentation of this file.
1
5
6#pragma once
7#include "Common.h"
10#include "System/String.h"
11
12namespace DotNetDupe {
13 namespace System {
14 namespace Threading {
21 class Semaphore : public LockWaitHandle {
22 public:
26 DOTNETDUPE_API Semaphore(int initialCount, int maximumCount);
27
33 DOTNETDUPE_API Semaphore(const String& sName, int initialCount = 0, int maximumCount = 1, bool openAlways = true);
34
40 DOTNETDUPE_API Semaphore(int initialCount, int maximumCount, const String& sName, bool openAlways = true);
41
48 DOTNETDUPE_API Semaphore(int initialCount, int maximumCount, const String& sName, bool openAlways, bool& bCreatedNew);
49
51 DOTNETDUPE_API ~Semaphore() override;
52
55 DOTNETDUPE_API bool WaitOne() override;
56
60 DOTNETDUPE_API bool WaitOne(int millisecondsTimeout) override;
61
66 DOTNETDUPE_API int Release(int releaseCount = 1) override;
67
73
78 DOTNETDUPE_API static bool TryOpenExisting(const String& sName, SmartPointer<Semaphore>& pResult);
79
80 struct Impl;
81 private:
82 int _count;
83 int _maxCount;
84 String _name;
85 void* _hHandle;
86 Impl* _pImpl;
87 };
88 }
89 }
90}
Defines common cross-platform macros, export decorators, and fundamental types.
#define DOTNETDUPE_API
Platform-specific linkage decoration for exporting or importing library symbols.
Definition Common.h:20
Provides reference-counted and weak pointer memory management primitives ensuring zero raw ownership.
High-performance UTF-8 / UTF-16 string manipulation class mirroring .NET System.String.
Base abstract classes for synchronization wait handles.
A unified smart pointer that supports both unique and shared ownership semantics.
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition String.h:74
Abstract base class for wait handles that support releasing acquire counts.
Definition WaitHandle.h:35
bool WaitOne() override
Blocks the current thread until the current WaitHandle receives a signal.
static bool TryOpenExisting(const String &sName, SmartPointer< Semaphore > &pResult)
Opens an existing named system semaphore, and returns a value that indicates whether the operation su...
int Release(int releaseCount=1) override
Exits the semaphore and returns the previous count.
static SmartPointer< Semaphore > OpenExisting(const String &sName)
Opens an existing named system semaphore.
Definition Semaphore.cpp:94
Semaphore(int initialCount, int maximumCount)
Initializes a new instance of the Semaphore class, specifying the initial number of entries and the m...
Definition Semaphore.cpp:27