/usr/include/caf/spawn_options.hpp is in libcaf-dev 0.13.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | /******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2015 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_SPAWN_OPTIONS_HPP
#define CAF_SPAWN_OPTIONS_HPP
namespace caf {
/**
* @ingroup ActorCreation
* @{
*/
/**
* Stores options passed to the `spawn` function family.
*/
#ifdef CAF_DOCUMENTATION
class spawn_options {};
#else
enum class spawn_options : int {
no_flags = 0x00,
link_flag = 0x01,
monitor_flag = 0x02,
detach_flag = 0x04,
hide_flag = 0x08,
blocking_api_flag = 0x10,
priority_aware_flag = 0x20,
lazy_init_flag = 0x40
};
#endif
/**
* Concatenates two {@link spawn_options}.
* @relates spawn_options
*/
constexpr spawn_options operator+(const spawn_options& lhs,
const spawn_options& rhs) {
return static_cast<spawn_options>(static_cast<int>(lhs) |
static_cast<int>(rhs));
}
/**
* Denotes default settings.
*/
constexpr spawn_options no_spawn_options = spawn_options::no_flags;
/**
* Causes `spawn` to call `self->monitor(...) immediately
* after the new actor was spawned.
*/
constexpr spawn_options monitored = spawn_options::monitor_flag;
/**
* Causes `spawn` to call `self->link_to(...) immediately
* after the new actor was spawned.
*/
constexpr spawn_options linked = spawn_options::link_flag;
/**
* Causes the new actor to opt out of the cooperative scheduling.
*/
constexpr spawn_options detached = spawn_options::detach_flag;
/**
* Causes the runtime to ignore the new actor in `await_all_actors_done()`.
*/
constexpr spawn_options hidden = spawn_options::hide_flag;
/**
* Causes the new actor to opt in to the blocking API,
* i.e., the actor uses a context-switching or thread-based backend
* instead of the default event-based implementation.
*/
constexpr spawn_options blocking_api = spawn_options::blocking_api_flag;
/**
* Causes the new actor to evaluate message priorities.
* @note This implicitly causes the actor to run in its own thread.
*/
constexpr spawn_options priority_aware = spawn_options::priority_aware_flag;
/**
* Causes the new actor to delay its
* initialization until a message arrives.
*/
constexpr spawn_options lazy_init = spawn_options::lazy_init_flag;
/**
* Checks wheter `haystack` contains `needle`.
* @relates spawn_options
*/
constexpr bool has_spawn_option(spawn_options haystack, spawn_options needle) {
return (static_cast<int>(haystack) & static_cast<int>(needle)) != 0;
}
/**
* Checks wheter the {@link detached} flag is set in `opts`.
* @relates spawn_options
*/
constexpr bool has_detach_flag(spawn_options opts) {
return has_spawn_option(opts, detached);
}
/**
* Checks wheter the {@link priority_aware} flag is set in `opts`.
* @relates spawn_options
*/
constexpr bool has_priority_aware_flag(spawn_options opts) {
return has_spawn_option(opts, priority_aware);
}
/**
* Checks wheter the {@link hidden} flag is set in `opts`.
* @relates spawn_options
*/
constexpr bool has_hide_flag(spawn_options opts) {
return has_spawn_option(opts, hidden);
}
/**
* Checks wheter the {@link linked} flag is set in `opts`.
* @relates spawn_options
*/
constexpr bool has_link_flag(spawn_options opts) {
return has_spawn_option(opts, linked);
}
/**
* Checks wheter the {@link monitored} flag is set in `opts`.
* @relates spawn_options
*/
constexpr bool has_monitor_flag(spawn_options opts) {
return has_spawn_option(opts, monitored);
}
/**
* Checks wheter the {@link blocking_api} flag is set in `opts`.
* @relates spawn_options
*/
constexpr bool has_blocking_api_flag(spawn_options opts) {
return has_spawn_option(opts, blocking_api);
}
/**
* Checks wheter the {@link lazy_init} flag is set in `opts`.
* @relates spawn_options
*/
constexpr bool has_lazy_init_flag(spawn_options opts) {
return has_spawn_option(opts, lazy_init);
}
/** @} */
/** @cond PRIVATE */
constexpr bool is_unbound(spawn_options opts) {
return !has_monitor_flag(opts) && !has_link_flag(opts);
}
constexpr spawn_options make_unbound(spawn_options opts) {
return static_cast<spawn_options>(
(static_cast<int>(opts) &
~(static_cast<int>(linked) | static_cast<int>(monitored))));
}
/** @endcond */
} // namespace caf
#endif // CAF_SPAWN_OPTIONS_HPP
|