File tree Expand file tree Collapse file tree 3 files changed +57
-3
lines changed Expand file tree Collapse file tree 3 files changed +57
-3
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright (c) 2020, Erik Henriksson
2
+ * Copyright (c) 2024, Niklas Hauser
3
3
*
4
4
* This file is part of the modm project.
5
5
*
9
9
*/
10
10
// ----------------------------------------------------------------------------
11
11
12
- #include " fiber/functions.hpp"
13
- #include " fiber/task.hpp"
12
+ /*
13
+ We use __has_include guards here to support the case when fibers are not in use
14
+ but we still need to provide the interface to the rest of the library.
15
+ Then only the functionality that is enabled is supported and the fiber yield()
16
+ function returns immediately, thus blocks in-place.
17
+ */
18
+
19
+ // includes the functions related to time
20
+ #if __has_include(<modm/architecture/interface/clock.hpp>)
21
+ # include " fiber/functions.hpp"
22
+ #endif
23
+ // polyfill implementation of an empty yield
24
+ #if __has_include("fiber/no_yield.hpp")
25
+ # include " fiber/no_yield.hpp"
26
+ #endif
27
+ // pulls in the fiber and scheduler implementation
28
+ #if __has_include("fiber/task.hpp")
29
+ # include " fiber/task.hpp"
30
+ #endif
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2023, Niklas Hauser
3
+ *
4
+ * This file is part of the modm project.
5
+ *
6
+ * This Source Code Form is subject to the terms of the Mozilla Public
7
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
8
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
+ */
10
+ // ----------------------------------------------------------------------------
11
+
12
+ #pragma once
13
+
14
+ // / @cond
15
+ namespace modm ::this_fiber
16
+ {
17
+
18
+ void inline
19
+ yield ()
20
+ {
21
+ // do nothing and return
22
+ }
23
+
24
+ modm::fiber::id inline
25
+ get_id ()
26
+ {
27
+ return 0 ;
28
+ }
29
+
30
+ } // namespace modm::this_fiber
31
+ // / @endcond
Original file line number Diff line number Diff line change @@ -27,6 +27,12 @@ def build(env):
27
27
env .outbasepath = "modm/src/modm/processing"
28
28
env .copy ("task.hpp" )
29
29
30
+ if not env .has_module (":processing:fiber" ):
31
+ env .outbasepath = "modm/src/modm/processing/"
32
+ env .copy ("fiber/functions.hpp" )
33
+ env .copy ("fiber/no_yield.hpp" )
34
+ env .copy ("fiber.hpp" )
35
+
30
36
env .outbasepath = "modm/src/modm"
31
37
headers = env .generated_local_files (filterfunc = lambda path : ".h" in path and not "_impl.h" in path )
32
38
env .template ("processing.hpp.in" , substitutions = {"headers" : sorted (headers )})
You can’t perform that action at this time.
0 commit comments