forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibThreading: Add new detach() API to Thread
Sometimes you don't care about `joining()` the result of a thread. The underlying pthread implementation already existed for detaching and now we expose it to the higher level API.
- Loading branch information
1 parent
5666809
commit 48731e9
Showing
2 changed files
with
14 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (c) 2019-2020, Sergey Bugaev <[email protected]> | ||
* Copyright (c) 2021, Spencer Dixon <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
@@ -24,6 +25,7 @@ class Thread final : public Core::Object { | |
virtual ~Thread(); | ||
|
||
void start(); | ||
void detach(); | ||
|
||
template<typename T = void> | ||
Result<T, ThreadError> join(); | ||
|
@@ -36,6 +38,7 @@ class Thread final : public Core::Object { | |
Function<intptr_t()> m_action; | ||
pthread_t m_tid { 0 }; | ||
String m_thread_name; | ||
bool m_detached { false }; | ||
}; | ||
|
||
template<typename T> | ||
|