49enum class ObjectType : u8 {
91 u32 obj_attributes_ptr);
106 u32 processor_mode, u32 alertable, u64* opt_timeout);
118 u32 wait_type, u32 wait_reason, u32 processor_mode,
119 u32 alertable, u64* opt_timeout);
131 const ObjectPin& wait_object, u32 wait_reason,
132 u32 processor_mode, u32 alertable, u64* opt_timeout);
138struct std::formatter<
rex::kernel::ObjectType> : std::formatter<rex::u32> {
139 auto format(rex::kernel::ObjectType value, std::format_context& ctx)
const {
140 return std::formatter<rex::u32>::format(
static_cast<rex::u32
>(value), ctx);
152 void Pin()
noexcept { count_.fetch_add(1, std::memory_order_acquire); }
159 [[nodiscard]]
bool Unpin() noexcept {
160 return count_.fetch_sub(1, std::memory_order_acq_rel) - 1 == kRetired;
169 return count_.fetch_or(kRetired, std::memory_order_acq_rel) == 0;
174 return count_.load(std::memory_order_acquire) & ~kRetired;
178 static constexpr u32 kRetired = 0x80000000u;
179 std::atomic<u32> count_{0};
192 PublishedPtr() =
default;
203 T*
get() noexcept {
return current_.load(std::memory_order_acquire); }
205 const T*
get() const noexcept {
return current_.load(std::memory_order_acquire); }
207 T* operator->() noexcept {
return get(); }
209 const T* operator->() const noexcept {
return get(); }
211 explicit operator bool() const noexcept {
return get() !=
nullptr; }
213 friend bool operator==(
const PublishedPtr& value, std::nullptr_t)
noexcept {
214 return value.get() ==
nullptr;
224 retired_.push_back(std::move(owner_));
226 owner_ = std::move(next);
227 current_.store(owner_.get(), std::memory_order_release);
235 [[nodiscard]] std::unique_ptr<T>
Take() noexcept {
236 current_.store(
nullptr, std::memory_order_relaxed);
237 return std::move(owner_);
241 std::atomic<T*> current_{
nullptr};
242 std::unique_ptr<T> owner_;
243 std::vector<std::unique_ptr<T>> retired_;
Definition object_pin.h:29
bool Retire() noexcept
Definition object.h:168
u32 GetPins() const noexcept
Definition object.h:173
bool Unpin() noexcept
Definition object.h:159
Definition object_pin.h:122
std::unique_ptr< T > Take() noexcept
Definition object.h:235
T * get() noexcept
Definition object.h:203
PublishedPtr(std::unique_ptr< T > owner)
Definition object.h:195
void Replace(std::unique_ptr< T > next)
Definition object.h:222
Definition title_runtime.h:85
X_STATUS Wait(TitleRuntime &runtime, const ObjectPin &object, u32 wait_reason, u32 processor_mode, u32 alertable, u64 *opt_timeout)
u32 X_STATUS
Definition status.h:23
X_STATUS SignalAndWait(TitleRuntime &runtime, const ObjectPin &signal_object, const ObjectPin &wait_object, u32 wait_reason, u32 processor_mode, u32 alertable, u64 *opt_timeout)
std::chrono::microseconds DelayFromTicks(i64 delay_ticks)
X_STATUS WaitMultiple(TitleRuntime &runtime, std::span< const ObjectPin > objects, u32 wait_type, u32 wait_reason, u32 processor_mode, u32 alertable, u64 *opt_timeout)
constexpr memory::FourCCT kStashSignature
Definition object.h:47
std::string NameFromAttributes(kernel::GuestAddressSpace *memory, u32 obj_attributes_ptr)
std::chrono::milliseconds TimeoutFromTicks(i64 timeout_ticks)
constexpr u32 kHandleBase
Definition object.h:64
u32 FourCCT
Definition endian.h:264
constexpr FourCCT make_fourcc(char a, char b, char c, char d)
Definition endian.h:273
Wait objects and wait functions.
Integer types, byte order wrappers and size literals.