xtd 0.2.0
Loading...
Searching...
No Matches
spin_lock.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../object.hpp"
6#include "../time_span.hpp"
7
9namespace xtd {
11 namespace threading {
36 class spin_lock : public object {
37 struct data;
38
39 public:
41
48 spin_lock(bool enable_thread_owner_tracking);
50
52 spin_lock(spin_lock&&) = default;
53 spin_lock(const spin_lock&) = default;
54 spin_lock& operator =(const spin_lock& other) = default;
56
58
62 bool is_held() const noexcept;
63
67 bool is_held_by_current_thread() const noexcept;
68
71 bool is_thread_owner_tracking_enabled() const noexcept;
73
75
81 void enter(bool& lock_taken);
82
87 void exit();
93 void exit(bool use_memory_barrier);
94
99 void try_enter(bool& lock_taken);
105 void try_enter(int32 milliseconds_timeout, bool& lock_taken);
111 void try_enter(const time_span& timeout, bool& lock_taken);
113
114 private:
115 mutable xtd::sptr<data> data_;
116 };
117 }
118}
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:42
Provides a mutual exclusion lock primitive where a thread trying to acquire the lock waits in a loop ...
Definition spin_lock.hpp:36
spin_lock(bool enable_thread_owner_tracking)
Initializes a new instance of the xtd::threading::spin_lock structure with the option to track thread...
void try_enter(bool &lock_taken)
Attempts to acquire the lock in a reliable manner, such that even if an exception occurs within the m...
bool is_thread_owner_tracking_enabled() const noexcept
Gets whether thread ownership tracking is enabled for this instance.
spin_lock()
Initializes a new instance of the xtd::threading::spin_lock structure.
void exit()
Releases the lock.
bool is_held_by_current_thread() const noexcept
Gets whether the lock is held by the current thread.
bool is_held() const noexcept
Gets whether the lock is currently held by any thread.
Contains a constant used to specify an infinite amount of time. This class cannot be inherited.
Definition timeout.hpp:33
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
@ other
The operating system is other.
@ enter
The ENTER key.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Represents a time interval.
Definition time_span.hpp:29