Skip to content

Commit

Permalink
Added method to get native handle for thread for advanced Threading a…
Browse files Browse the repository at this point in the history
…ctions
  • Loading branch information
markoostveen committed Dec 19, 2023
1 parent 1b3caf4 commit f087b60
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions JobSystem/Src/JobSystem/WorkerThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,10 @@ namespace JbSystem
return _jobsystem->GetWorkerId(this);
}

std::thread::native_handle_type JobSystemWorker::WorkerNativeThreadHandle()
std::thread::native_handle_type JobSystemWorker::WorkerNativeThreadHandle() const
{
return _worker.native_handle();
// Getting this handle won't compromise the workerthread
return const_cast<std::thread*>(&_worker)->native_handle();
}

bool JobSystemWorker::ExecutePausedJob()
Expand Down
2 changes: 1 addition & 1 deletion JobSystem/Src/JobSystem/WorkerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace JbSystem
void WaitForShutdown();
void Start(); // Useful when thread became lost for some reason
int WorkerId();
std::thread::native_handle_type WorkerNativeThreadHandle();
std::thread::native_handle_type WorkerNativeThreadHandle() const;

bool ExecutePausedJob();
bool ExecutePausedJob(JobSystemWorker& executingWorker);
Expand Down

0 comments on commit f087b60

Please sign in to comment.