Skip to content

Commit a5870f3

Browse files
committed
thread: refine the joinable implementation
1 parent 6488573 commit a5870f3

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/uvw/thread.ipp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,8 @@ UVW_INLINE bool thread::run(create_flags opts, std::size_t stack) noexcept {
5959
}
6060

6161
UVW_INLINE bool thread::join() noexcept {
62-
if(joinable) {
63-
joinable = false;
64-
return (0 == uv_thread_join(raw()));
65-
}
66-
67-
return true;
62+
const auto was_joinable = std::exchange(joinable, false);
63+
return was_joinable ? (0 == uv_thread_join(raw())) : true;
6864
}
6965

7066
UVW_INLINE thread_local_storage::thread_local_storage(loop::token token, std::shared_ptr<loop> ref) noexcept

0 commit comments

Comments
 (0)