CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
monitor.h
1
2#pragma once
3#include <system/timespan.h>
4#include <system/shared_ptr.h>
5#include <system/object.h>
6#include <system/exceptions.h>
7#include <cstdint>
8
9namespace System { namespace Threading {
10
78class ASPOSECPP_SHARED_CLASS Monitor : public System::Object
79{
80 typedef Monitor ThisType;
82
83 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
84 RTTI_INFO_DECL();
85
86public:
90 ASPOSECPP_SHARED_API static void Enter(const SharedPtr<Object>& obj);
93 static ASPOSECPP_SHARED_API void Enter(const System::SharedPtr<Object>& obj, bool& lockTaken);
98 ASPOSECPP_SHARED_API static void Exit(const SharedPtr<Object>& obj);
102 ASPOSECPP_SHARED_API static bool TryEnter(const SharedPtr<Object>& obj);
105 static ASPOSECPP_SHARED_API void TryEnter(const System::SharedPtr<Object>& obj, bool& lockTaken);
109 ASPOSECPP_SHARED_API static bool TryEnter(const SharedPtr<Object>& obj, int32_t millisecondsTimeout);
113 ASPOSECPP_SHARED_API static bool TryEnter(const SharedPtr<Object>& obj, TimeSpan timeout);
116 static ASPOSECPP_SHARED_API void TryEnter(const System::SharedPtr<Object>& obj, int32_t millisecondsTimeout,
117 bool& lockTaken);
120 static ASPOSECPP_SHARED_API void TryEnter(const System::SharedPtr<Object>& obj, TimeSpan timeout, bool& lockTaken);
122 static ASPOSECPP_SHARED_API bool IsEntered(const System::SharedPtr<Object>& obj);
129 ASPOSECPP_SHARED_API static bool Wait(const SharedPtr<Object>& obj, int32_t millisecondsTimeout, bool exitContext);
136 ASPOSECPP_SHARED_API static bool Wait(const SharedPtr<Object>& obj, TimeSpan timeout, bool exitContext);
141 ASPOSECPP_SHARED_API static bool Wait(const SharedPtr<Object>& obj, int32_t millisecondsTimeout);
146 ASPOSECPP_SHARED_API static bool Wait(const SharedPtr<Object>& obj, TimeSpan timeout);
150 ASPOSECPP_SHARED_API static bool Wait(const SharedPtr<Object>& obj);
154 ASPOSECPP_SHARED_API static void Pulse(const SharedPtr<Object>& obj);
158 ASPOSECPP_SHARED_API static void PulseAll(const SharedPtr<Object>& obj);
159
160private:
161 static std::vector<SharedPtr<Object>> m_locked;
162};
163
164}} // namespace System::Threading
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Class Monitor provides a mechanism that synchronizes access to objects.
Definition: monitor.h:79
static bool Wait(const SharedPtr< Object > &obj, int32_t millisecondsTimeout)
Releases the lock on an object and blocks the current thread until it reacquires the lock....
static void Exit(const SharedPtr< Object > &obj)
Releases an exclusive lock on the specified object.
static void Enter(const SharedPtr< Object > &obj)
Acquires an exclusive lock on a specified object.
static bool Wait(const SharedPtr< Object > &obj, int32_t millisecondsTimeout, bool exitContext)
Releases the lock on an object and blocks the current thread until it reacquires the lock....
static void TryEnter(const System::SharedPtr< Object > &obj, int32_t millisecondsTimeout, bool &lockTaken)
Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object,...
static void TryEnter(const System::SharedPtr< Object > &obj, TimeSpan timeout, bool &lockTaken)
Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object,...
static bool TryEnter(const SharedPtr< Object > &obj, int32_t millisecondsTimeout)
Attempts, for the specified number of milliseconds, to acquire an exclusive lock on the specified obj...
static bool TryEnter(const SharedPtr< Object > &obj, TimeSpan timeout)
Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object Not ...
static bool Wait(const SharedPtr< Object > &obj, TimeSpan timeout)
Releases the lock on an object and blocks the current thread until it reacquires the lock....
static bool IsEntered(const System::SharedPtr< Object > &obj)
Determines whether the current thread holds the lock on the specified object.
static void Pulse(const SharedPtr< Object > &obj)
Notifies a thread in the waiting queue of a change in the locked object's state Not implemented.
static void PulseAll(const SharedPtr< Object > &obj)
Notifies all waiting threads of a change in the object's state Not implemented.
static void TryEnter(const System::SharedPtr< Object > &obj, bool &lockTaken)
Attempts to acquire an exclusive lock on the specified object, and atomically sets a value that indic...
static bool Wait(const SharedPtr< Object > &obj)
Releases the lock on an object and blocks the current thread until it reacquires the lock Not impleme...
static void Enter(const System::SharedPtr< Object > &obj, bool &lockTaken)
Acquires an exclusive lock on the specified object, and atomically sets a value that indicates whethe...
static bool TryEnter(const SharedPtr< Object > &obj)
Attempts to acquire an exclusive lock on the specified object Not implemented.
static bool Wait(const SharedPtr< Object > &obj, TimeSpan timeout, bool exitContext)
Releases the lock on an object and blocks the current thread until it reacquires the lock....
Represents a time interval. This type should be allocated on stack and passed to functions by value o...
Definition: timespan.h:59
Definition: db_command.h:9