-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pw_thread: Move pw::thread::Options to its own header
This makes it possible to work with Options without relying on the thread facade. Change-Id: Ia8cd3dab9d2ba0a6d82081ffea06b00d26014a1c Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/232151 Lint: Lint 🤖 <[email protected]> Reviewed-by: Ewout van Bekkum <[email protected]> Commit-Queue: Wyatt Hepler <[email protected]> Pigweed-Auto-Submit: Wyatt Hepler <[email protected]>
- Loading branch information
Showing
7 changed files
with
72 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2024 The Pigweed Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
// use this file except in compliance with the License. You may obtain a copy of | ||
// the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
// License for the specific language governing permissions and limitations under | ||
// the License. | ||
#pragma once | ||
|
||
namespace pw::thread { | ||
|
||
/// The Options contains the parameters needed for a thread to start. | ||
/// | ||
/// Options are backend specific and ergo the generic base class cannot be | ||
/// directly instantiated. | ||
/// | ||
/// The attributes which can be set through the options are backend specific | ||
/// but may contain things like the thread name, priority, scheduling policy, | ||
/// core/processor affinity, and/or an optional reference to a pre-allocated | ||
/// Context (the collection of memory allocations needed for a thread to run). | ||
/// | ||
/// Options shall NOT have an attribute to start threads as detached vs | ||
/// joinable. All `pw::thread::Thread` instances must be explicitly `join()`'d | ||
/// or `detach()`'d through the run-time Thread API. | ||
/// | ||
/// Note that if backends set `PW_THREAD_JOINING_ENABLED` to false, backends may | ||
/// use native OS specific APIs to create native detached threads because the | ||
/// `join()` API would be compiled out. However, users must still explicitly | ||
/// invoke `detach()`. | ||
/// | ||
/// Options must not contain any memory needed for a thread to run (TCB, | ||
/// stack, etc.). The Options may be deleted or re-used immediately after | ||
/// starting a thread. | ||
class Options { | ||
protected: | ||
// We can't use `= default` here, because it allows to create an Options | ||
// instance in C++17 with `pw::thread::Options{}` syntax. | ||
constexpr Options() {} | ||
}; | ||
|
||
} // namespace pw::thread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters