Symbian platform (C++)
SDK native APIs, runtime and tooling
Loading...
Searching...
No Matches
inline_pump.h
Go to the documentation of this file.
1// Copyright 2026 The A11 Authors.
2// Licensed under the Apache License, Version 2.0 (the "License");
3// http://www.apache.org/licenses/LICENSE-2.0
4//
5// Guest no-exceptions adaptation of A11
6// cpp/a11/concurrency/inline_pump.h at
7// fcccb8cb6e1e67d7ba0822ac14cece9ee4c7091b.
8
9#ifndef SYMBIAN_CONCURRENCY_INLINE_PUMP_H_
10#define SYMBIAN_CONCURRENCY_INLINE_PUMP_H_
11
12#include <cstddef>
13#include <string_view>
14#include <utility>
15
16#include "thread/boost_primitives.h"
17
18namespace symbian::concurrency {
19
21 size_t depth = 0;
22 bool again = false;
23};
24
25template <typename Once>
27 [[maybe_unused]] std::string_view name, Once&& once,
28 size_t max_depth = 4) {
29 {
30 thread::MutexLock lock(mu);
31 if (state->depth >= max_depth) {
32 state->again = true;
33 return;
34 }
35 ++state->depth;
36 }
37 while (true) {
38 once();
39 thread::MutexLock lock(mu);
40 if (!state->again) {
41 --state->depth;
42 return;
43 }
44 state->again = false;
45 }
46}
47
48// The caller must hold the same mutex passed to DriveInline.
49inline bool PumpIsDriving(const InlinePumpState& state) {
50 return state.depth > 0;
51}
52
53} // namespace symbian::concurrency
54
55#endif // SYMBIAN_CONCURRENCY_INLINE_PUMP_H_
Definition bounded_channel.h:38
Definition boost_primitives.h:95
Definition boost_primitives.h:34
Definition bounded_channel.h:32
void DriveInline(thread::Mutex *mu, InlinePumpState *state, std::string_view name, Once &&once, size_t max_depth=4)
Definition inline_pump.h:26
bool PumpIsDriving(const InlinePumpState &state)
Definition inline_pump.h:49
Definition inline_pump.h:20
size_t depth
Definition inline_pump.h:21
bool again
Definition inline_pump.h:22