Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
z
Classes
Class List
Class Hierarchy
Class Members
All
:
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Properties
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Related Functions
:
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
grpc
test
core
gpr
tls_test.cc
Go to the documentation of this file.
1
/*
2
*
3
* Copyright 2015 gRPC authors.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*/
18
19
/* Test of gpr thread local storage support. */
20
21
#include "
src/core/lib/gpr/tls.h
"
22
23
#include <array>
24
25
#include <gtest/gtest.h>
26
27
#include "
src/core/lib/gprpp/thd.h
"
28
#include "
test/core/util/test_config.h
"
29
30
struct
BiggerThanMachineWord
{
31
size_t
a
,
b
;
32
uint8_t
c
;
33
};
34
35
static
GPR_THREAD_LOCAL
(
BiggerThanMachineWord
)
test_var
;
36
// Fails to compile: static GPR_THREAD_LOCAL(std::unique_ptr<char>) non_trivial;
37
38
namespace
{
39
void
thd_body(
void
*) {
40
for
(
size_t
i
= 0;
i
< 100000;
i
++) {
41
BiggerThanMachineWord
next
= {
i
,
i
,
uint8_t
(
i
)};
42
test_var
=
next
;
43
BiggerThanMachineWord
read
=
test_var
;
44
ASSERT_EQ
(
read
.a,
i
);
45
ASSERT_EQ
(
read
.b,
i
);
46
ASSERT_EQ
(
read
.c,
uint8_t
(
i
)) <<
i
;
47
}
48
}
49
50
TEST
(ThreadLocal, ReadWrite) {
51
std::array<grpc_core::Thread, 100>
threads
;
52
for
(
grpc_core::Thread
& th :
threads
) {
53
th =
grpc_core::Thread
(
"grpc_tls_test"
, thd_body,
nullptr
);
54
th.Start();
55
}
56
for
(
grpc_core::Thread
& th :
threads
) {
57
th.Join();
58
}
59
}
60
61
}
// namespace
62
63
int
main
(
int
argc,
char
* argv[]) {
64
grpc::testing::TestEnvironment
env
(&argc, argv);
65
::testing::InitGoogleTest
(&argc, argv);
66
return
RUN_ALL_TESTS
();
67
}
BiggerThanMachineWord
Definition:
tls_test.cc:30
generate.env
env
Definition:
generate.py:37
BiggerThanMachineWord::c
uint8_t c
Definition:
tls_test.cc:32
tests.unit._contextvars_propagation_test.test_var
test_var
Definition:
_contextvars_propagation_test.py:70
uint8_t
unsigned char uint8_t
Definition:
stdint-msvc2008.h:78
threads
static uv_thread_t * threads
Definition:
threadpool.c:38
TEST
#define TEST(name, init_size,...)
Definition:
arena_test.cc:75
RUN_ALL_TESTS
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition:
bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2471
BiggerThanMachineWord::b
size_t b
Definition:
tls_test.cc:31
test_config.h
read
int read(izstream &zs, T *x, Items items)
Definition:
bloaty/third_party/zlib/contrib/iostream2/zstream.h:115
testing::InitGoogleTest
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition:
bloaty/third_party/googletest/googletest/src/gtest.cc:6106
GPR_THREAD_LOCAL
static GPR_THREAD_LOCAL(BiggerThanMachineWord) test_var
main
int main(int argc, char *argv[])
Definition:
tls_test.cc:63
next
AllocList * next[kMaxLevel]
Definition:
abseil-cpp/absl/base/internal/low_level_alloc.cc:100
grpc::testing::TestEnvironment
Definition:
test/core/util/test_config.h:54
thd.h
tls.h
grpc_core::Thread
Definition:
thd.h:43
BiggerThanMachineWord::a
size_t a
Definition:
tls_test.cc:31
i
uint64_t i
Definition:
abseil-cpp/absl/container/btree_benchmark.cc:230
ASSERT_EQ
#define ASSERT_EQ(val1, val2)
Definition:
bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2056
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:40