Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion iocore/eventsystem/I_Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
#include "tscore/ink_thread.h"
#include "I_ProxyAllocator.h"

#include <atomic>

class ProxyMutex;

constexpr int MAX_THREAD_NAME_LENGTH = 16;
Expand Down Expand Up @@ -177,7 +179,7 @@ class Thread
protected:
Thread();

static ink_hrtime cur_time;
static std::atomic<ink_hrtime> cur_time;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thread::cur_time is shared across threads.

@note The cached copy shared among threads which means the cached copy is updated
for all threads if any thread updates it.

};

extern Thread *this_thread();
Expand Down
2 changes: 1 addition & 1 deletion iocore/eventsystem/Thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// Common Interface impl //
///////////////////////////////////////////////

ink_hrtime Thread::cur_time = ink_get_hrtime_internal();
std::atomic<ink_hrtime> Thread::cur_time = ink_get_hrtime_internal();
thread_local Thread *Thread::this_thread_ptr;

Thread::Thread()
Expand Down