Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplify definition
  • Loading branch information
Gabriel Schulhof committed Apr 13, 2020
commit 8980c7b27213aa0f76e83e9cacc70dbdea8f75f3
20 changes: 7 additions & 13 deletions src/node_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,30 +116,24 @@ static inline void trigger_fatal_exception(
class ThreadID {
public:
#ifdef _WIN32
typedef DWORD thread_id_t;
ThreadID(): _tid(GetCurrentThreadId()) {}
inline bool operator==(const ThreadID& other) { return _tid == other._tid; }
#else
typedef uv_thread_t thread_id_t;
ThreadID(): _tid(uv_thread_self()) {}
inline bool operator==(const ThreadID& other) {
return static_cast<bool>(uv_thread_equal(&_tid, &other._tid));
}
#endif // _WIN32

ThreadID(const ThreadID&) = delete;
ThreadID(ThreadID&&) = delete;
void operator= (const ThreadID&) = delete;
void operator= (const ThreadID&&) = delete;

#ifdef _WIN32
inline bool operator==(const ThreadID& other) { return _tid == other._tid; }
#else
inline bool operator==(const ThreadID& other) {
return static_cast<bool>(uv_thread_equal(&_tid, &other._tid));
}
#endif

private:
#ifdef _WIN32
DWORD _tid = 0;
#else
uv_thread_t _tid;
#endif // _WIN32
thread_id_t _tid;
};

class ThreadSafeFunction : public node::AsyncResource {
Expand Down