Flow 1.0.2
Flow project: Full implementation reference.
async.cpp
Go to the documentation of this file.
1/* Flow
2 * Copyright 2023 Akamai Technologies, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the
5 * "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy
7 * of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in
12 * writing, software distributed under the License is
13 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14 * CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing
16 * permissions and limitations under the License. */
17
18/// @file
19
21#include "flow/common.hpp"
22#include <limits>
23#ifdef FLOW_OS_LINUX
24# include <sched.h>
25#endif
26
27namespace flow::async
28{
29
30uint16_t cpu_idx()
31{
32 using std::numeric_limits;
33 using ret_int_t = uint16_t;
34
35#ifdef FLOW_OS_LINUX
36 using ::sched_getcpu;
37
38 return ret_int_t(sched_getcpu());
39#else
40 static_assert(false, "cpu_idx() implementation is for Linux. "
41 "Revisit for other OS and/or architectures (x86-64, ARM64, ...).");
42#endif
43}
44
45} // namespace flow::async
Flow module containing tools enabling multi-threaded event loops operating under the asynchronous-tas...
Definition: async_fwd.hpp:75
uint16_t cpu_idx()
Returns the 0-based processor logical (not hardware) core index of the core executing the calling thr...
Definition: async.cpp:30