Skip to content

Commit

Permalink
reduce the number of ifdefs
Browse files Browse the repository at this point in the history
  • Loading branch information
jesswong committed Dec 4, 2024
1 parent 3b1b1d8 commit 6f28bfe
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions source/async_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ struct AsyncStackRootHolderList {
extern "C" {
auto* kUnifexAsyncStackRootHolderList = new AsyncStackRootHolderList();
}
#endif // UNIFEX_ASYNC_STACK_ROOT_USE_PTHREAD == 0

#if !UNIFEX_ASYNC_STACK_ROOT_USE_PTHREAD
namespace utils {
static std::uint64_t get_os_thread_id() {
# if defined(__APPLE__)
Expand All @@ -107,7 +105,7 @@ static std::uint64_t get_os_thread_id() {
# endif
}
} // namespace utils
#endif // !UNIFEX_ASYNC_STACK_ROOT_USE_PTHREAD
#endif // UNIFEX_ASYNC_STACK_ROOT_USE_PTHREAD == 0

namespace {

Expand Down Expand Up @@ -146,6 +144,9 @@ struct AsyncStackRootHolder {
~AsyncStackRootHolder() noexcept {
kUnifexAsyncStackRootHolderList->remove(this);
}

std::uint64_t get_thread_id() const noexcept { return threadId; }

#endif

AsyncStackRoot* get() const noexcept {
Expand All @@ -160,10 +161,6 @@ struct AsyncStackRootHolder {
value.store(root, std::memory_order_relaxed);
}

#if !UNIFEX_ASYNC_STACK_ROOT_USE_PTHREAD
std::uint64_t get_thread_id() const noexcept { return threadId; }
#endif

std::atomic<AsyncStackRoot*> value{nullptr};
#if !UNIFEX_ASYNC_STACK_ROOT_USE_PTHREAD
std::uint64_t threadId = 0;
Expand Down

0 comments on commit 6f28bfe

Please sign in to comment.