Skip to content

Commit

Permalink
src: make main_thread_id_ atomic
Browse files Browse the repository at this point in the history
The value access needs to be thread safe.

PR-URL: #24
Reviewed-by: Santiago Gimeno <[email protected]>
  • Loading branch information
trevnorris committed Nov 13, 2023
1 parent ffb241f commit d849d3f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/nsolid/nsolid_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ class EnvList {
nsuv::ns_mutex map_lock_;
// A map of all Environments in the process.
std::map<uint64_t, SharedEnvInst> env_map_;
uint64_t main_thread_id_ = 0xFFFFFFFFFFFFFFFF;
std::atomic<uint64_t> main_thread_id_ = {0xFFFFFFFFFFFFFFFF};
// Lock EnvList while all command queues are being processed. This is to
// prevent ~EnvList from running while processing all commands.
nsuv::ns_mutex command_lock_;
Expand Down

0 comments on commit d849d3f

Please sign in to comment.