MCPcopy Create free account
hub / github.com/apache/brpc / ThreadLocalStorageRunner

Class ThreadLocalStorageRunner

test/thread_local_storage_unittest.cc:31–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29static ThreadLocalStorage::StaticSlot tls_slot = TLS_INITIALIZER;
30
31class ThreadLocalStorageRunner : public DelegateSimpleThread::Delegate {
32 public:
33 explicit ThreadLocalStorageRunner(int* tls_value_ptr)
34 : tls_value_ptr_(tls_value_ptr) {}
35
36 virtual ~ThreadLocalStorageRunner() {}
37
38 virtual void Run() OVERRIDE {
39 *tls_value_ptr_ = kInitialTlsValue;
40 tls_slot.Set(tls_value_ptr_);
41
42 int *ptr = static_cast<int*>(tls_slot.Get());
43 EXPECT_EQ(ptr, tls_value_ptr_);
44 EXPECT_EQ(*ptr, kInitialTlsValue);
45 *tls_value_ptr_ = 0;
46
47 ptr = static_cast<int*>(tls_slot.Get());
48 EXPECT_EQ(ptr, tls_value_ptr_);
49 EXPECT_EQ(*ptr, 0);
50
51 *ptr = kFinalTlsValue + kNumberDestructorCallRepetitions;
52 }
53
54 private:
55 int* tls_value_ptr_;
56 DISALLOW_COPY_AND_ASSIGN(ThreadLocalStorageRunner);
57};
58
59
60void ThreadLocalStorageCleanup(void *value) {

Callers

nothing calls this directly

Calls 2

SetMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected