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/nullability.h>
15
16#include "absl/base/thread_annotations.h"
17#include "absl/time/time.h"
18
19namespace thread {
20
21inline constexpr bool kCanParkAwait = true;
22
23inline bool CanParkAwait() noexcept {
24 return true;
25}
26
27class ABSL_LOCKABLE Mutex {
28 public:
30 ~Mutex();
31 Mutex(const Mutex&) = delete;
32 Mutex& operator=(const Mutex&) = delete;
33
34 void Lock() noexcept ABSL_EXCLUSIVE_LOCK_FUNCTION();
35 void Unlock() noexcept ABSL_UNLOCK_FUNCTION();
36
37 void lock() noexcept ABSL_EXCLUSIVE_LOCK_FUNCTION() { Lock(); }
38
39 void unlock() noexcept ABSL_UNLOCK_FUNCTION() { Unlock(); }
40
41 private:
42 friend class CondVar;
43 struct Impl;
44 static constexpr std::size_t kImplSize = 64;
45 alignas(std::max_align_t) std::byte impl_[kImplSize];
46 Impl* absl_nonnull GetImpl();
47};
48
49class ABSL_SCOPED_LOCKABLE MutexLock {
50 public:
51 explicit MutexLock(Mutex* absl_nonnull mu) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
52 : mu_(mu) {
53 mu_->Lock();
54 }
55
56 MutexLock(const MutexLock&) = delete;
57 MutexLock& operator=(const MutexLock&) = delete;
58
59 ~MutexLock() ABSL_UNLOCK_FUNCTION() { mu_->Unlock(); }
60
61 private:
62 Mutex* absl_nonnull mu_;
63};
64
65class CondVar {
66 public:
68 ~CondVar();
69 CondVar(const CondVar&) = delete;
70 CondVar& operator=(const CondVar&) = delete;
71
72 void Wait(Mutex* absl_nonnull mu) noexcept;
73 // Matches A11: true on timeout, false on a signal. Recheck predicates
74 // after any wakeup. An accepted absolute deadline becomes steady elapsed
75 // time, so later wall-clock adjustments do not change that wait.
76 bool WaitWithDeadline(Mutex* absl_nonnull mu, absl::Time deadline) noexcept;
77 bool WaitWithTimeout(Mutex* absl_nonnull mu, absl::Duration timeout) noexcept;
78 void Signal() noexcept;
79 void SignalAll() noexcept;
80
81 private:
82 struct Impl;
83 static constexpr std::size_t kImplSize = 64;
84 alignas(std::max_align_t) std::byte impl_[kImplSize];
85 Impl* absl_nonnull GetImpl();
86};
87
88void SleepFor(absl::Duration duration);
89
90} // namespace thread
91
92#endif // THREAD_BOOST_PRIMITIVES_H_
Definition boost_primitives.h:113
void Signal() noexcept
bool WaitWithTimeout(Mutex *absl_nonnull mu, absl::Duration timeout) noexcept
void Wait(Mutex *absl_nonnull mu) noexcept
bool WaitWithDeadline(Mutex *absl_nonnull mu, absl::Time deadline) noexcept
CondVar(const CondVar &)=delete
void SignalAll() noexcept
Definition boost_primitives.h:234
~CondVar()
Definition boost_primitives.cc:62
CondVar & operator=(const CondVar &)=delete
Definition boost_primitives.h:97
~MutexLock() ABSL_UNLOCK_FUNCTION()
Definition boost_primitives.h:59
MutexLock(Mutex *absl_nonnull mu) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
Definition boost_primitives.h:51
MutexLock(const MutexLock &)=delete
MutexLock & operator=(const MutexLock &)=delete
Definition boost_primitives.h:36
void Lock() noexcept ABSL_EXCLUSIVE_LOCK_FUNCTION()
Mutex & operator=(const Mutex &)=delete
void unlock() noexcept ABSL_UNLOCK_FUNCTION()
Definition boost_primitives.h:39
Mutex(const Mutex &)=delete
Definition native_camera_stream.cc:19
Definition channel.h:29
void SleepFor(absl::Duration duration)
Definition boost_primitives.h:267
constexpr bool kCanParkAwait
Definition boost_primitives.h:30
bool CanParkAwait() noexcept
Definition boost_primitives.h:32
Definition boost_primitives.cc:51