1 // Copyright 2020 The Pigweed Authors
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
7 // https://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
19 namespace pw::thread::backend {
21 // Instead of using a pw::thread::freertos specific identifier, the FreeRTOS
22 // task handle is used as this means pw::this_thread::id works correctly on
23 // threads started with the native FreeRTOS APIs as well as those started
24 // using the pw::thread APIs.
27 constexpr NativeId(TaskHandle_t task_handle = nullptr)
28 : task_handle_(task_handle) {}
30 constexpr bool operator==(NativeId other) const {
31 return task_handle_ == other.task_handle_;
33 constexpr bool operator!=(NativeId other) const {
34 return task_handle_ != other.task_handle_;
36 constexpr bool operator<(NativeId other) const {
37 return task_handle_ < other.task_handle_;
39 constexpr bool operator<=(NativeId other) const {
40 return task_handle_ <= other.task_handle_;
42 constexpr bool operator>(NativeId other) const {
43 return task_handle_ > other.task_handle_;
45 constexpr bool operator>=(NativeId other) const {
46 return task_handle_ >= other.task_handle_;
50 TaskHandle_t task_handle_;
53 } // namespace pw::thread::backend