Symbian platform (C++)
SDK native APIs, runtime and tooling
Loading...
Searching...
No Matches
boost_primitives.h
Go to the documentation of this file.
1// Copyright 2026 The Action Engine Authors and the Symbian SDK Authors.
2// Licensed under the Apache License, Version 2.0 (the "License");
3// http://www.apache.org/licenses/LICENSE-2.0
4//
5// Boost-free public ABI adapted from A11 cpp/thread/thread/boost_primitives.h
6// at fcccb8cb6e1e67d7ba0822ac14cece9ee4c7091b. Boost is private to the
7// host implementation; guest builds select a different primitive header.
8
9#ifndef THREAD_BOOST_PRIMITIVES_H_
10#define THREAD_BOOST_PRIMITIVES_H_
11
12#include <cstddef>
13
14#include "absl/base/thread_annotations.h"
15#include "absl/time/time.h"
16
17namespace thread {
18
19inline constexpr bool kCanParkAwait = true;
20
21inline bool CanParkAwait() noexcept {
22 return true;
23}
24
25class ABSL_LOCKABLE Mutex {
26 public:
28 ~Mutex();
29 Mutex(const Mutex&) = delete;
30 Mutex& operator=(const Mutex&) = delete;
31
32 void Lock() noexcept ABSL_EXCLUSIVE_LOCK_FUNCTION();
33 void Unlock() noexcept ABSL_UNLOCK_FUNCTION();
34
35 void lock() noexcept ABSL_EXCLUSIVE_LOCK_FUNCTION() { Lock(); }
36
37 void unlock() noexcept ABSL_UNLOCK_FUNCTION() { Unlock(); }
38
39 private:
40 friend class CondVar;
41 struct Impl;
42 static constexpr std::size_t kImplSize = 64;
43 alignas(std::max_align_t) std::byte impl_[kImplSize];
44 Impl* GetImpl();
45};
46
47class ABSL_SCOPED_LOCKABLE MutexLock {
48 public:
49 explicit MutexLock(Mutex* mu) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu) : mu_(mu) {
50 mu_->Lock();
51 }
52
53 MutexLock(const MutexLock&) = delete;
54 MutexLock& operator=(const MutexLock&) = delete;
55
56 ~MutexLock() ABSL_UNLOCK_FUNCTION() { mu_->Unlock(); }
57
58 private:
59 Mutex* mu_;
60};
61
62class CondVar {
63 public:
65 ~CondVar();
66 CondVar(const CondVar&) = delete;
67 CondVar& operator=(const CondVar&) = delete;
68
69 void Wait(Mutex* mu) noexcept;
70 // Matches A11: true on timeout, false on a signal. Recheck predicates
71 // after any wakeup. An accepted absolute deadline becomes steady elapsed
72 // time, so later wall-clock adjustments do not change that wait.
73 bool WaitWithDeadline(Mutex* mu, absl::Time deadline) noexcept;
74 bool WaitWithTimeout(Mutex* mu, absl::Duration timeout) noexcept;
75 void Signal() noexcept;
76 void SignalAll() noexcept;
77
78 private:
79 struct Impl;
80 static constexpr std::size_t kImplSize = 64;
81 alignas(std::max_align_t) std::byte impl_[kImplSize];
82 Impl* GetImpl();
83};
84
85void SleepFor(absl::Duration duration);
86
87} // namespace thread
88
89#endif // THREAD_BOOST_PRIMITIVES_H_
Definition boost_primitives.h:110
void Signal() noexcept
CondVar(const CondVar &)=delete
void Wait(Mutex *mu) noexcept
void SignalAll() noexcept
Definition boost_primitives.h:230
bool WaitWithDeadline(Mutex *mu, absl::Time deadline) noexcept
~CondVar()
Definition boost_primitives.cc:61
CondVar & operator=(const CondVar &)=delete
bool WaitWithTimeout(Mutex *mu, absl::Duration timeout) noexcept
Definition boost_primitives.h:95
~MutexLock() ABSL_UNLOCK_FUNCTION()
Definition boost_primitives.h:56
MutexLock(Mutex *mu) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
Definition boost_primitives.h:49
MutexLock(const MutexLock &)=delete
MutexLock & operator=(const MutexLock &)=delete
Definition boost_primitives.h:34
void Lock() noexcept ABSL_EXCLUSIVE_LOCK_FUNCTION()
Mutex & operator=(const Mutex &)=delete
void unlock() noexcept ABSL_UNLOCK_FUNCTION()
Definition boost_primitives.h:37
Mutex(const Mutex &)=delete
Definition exception_count.cc:8
Definition channel.h:29
void SleepFor(absl::Duration duration)
Definition boost_primitives.h:263
constexpr bool kCanParkAwait
Definition boost_primitives.h:28
bool CanParkAwait() noexcept
Definition boost_primitives.h:30
Definition boost_primitives.cc:50