1 // Copyright 2020 The Pigweed Authors 2 // 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 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 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 13 // the License. 14 #pragma once 15 16 #include <thread> 17 18 #include "pw_thread/thread.h" 19 20 namespace pw::thread { 21 Thread()22inline Thread::Thread() : native_type_() {} 23 Thread(const Options &,ThreadRoutine entry,void * arg)24inline Thread::Thread(const Options&, ThreadRoutine entry, void* arg) { 25 native_type_ = std::thread(entry, arg); 26 } 27 28 inline Thread& Thread::operator=(Thread&& other) { 29 native_type_ = std::move(other.native_type_); 30 return *this; 31 } 32 33 inline Thread::~Thread() = default; 34 get_id()35inline Id Thread::get_id() const { return native_type_.get_id(); } 36 join()37inline void Thread::join() { native_type_.join(); } 38 detach()39inline void Thread::detach() { native_type_.detach(); } 40 swap(Thread & other)41inline void Thread::swap(Thread& other) { 42 native_type_.swap(other.native_handle()); 43 } 44 native_handle()45inline Thread::native_handle_type Thread::native_handle() { 46 return native_type_; 47 } 48 49 } // namespace pw::thread 50