• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright 2017 The Abseil Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      https://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17load(
18    "//absl:copts/configure_copts.bzl",
19    "ABSL_DEFAULT_COPTS",
20    "ABSL_DEFAULT_LINKOPTS",
21    "ABSL_TEST_COPTS",
22)
23
24package(
25    default_visibility = ["//visibility:private"],
26    features = [
27        "header_modules",
28        "layering_check",
29        "parse_headers",
30    ],
31)
32
33licenses(["notice"])
34
35# Internal data structure for efficiently detecting mutex dependency cycles
36cc_library(
37    name = "graphcycles_internal",
38    srcs = [
39        "internal/graphcycles.cc",
40    ],
41    hdrs = [
42        "internal/graphcycles.h",
43    ],
44    copts = ABSL_DEFAULT_COPTS + select({
45        "//conditions:default": [],
46    }),
47    linkopts = ABSL_DEFAULT_LINKOPTS,
48    deps = [
49        "//absl/base",
50        "//absl/base:base_internal",
51        "//absl/base:config",
52        "//absl/base:core_headers",
53        "//absl/base:malloc_internal",
54        "//absl/base:raw_logging_internal",
55    ],
56)
57
58cc_library(
59    name = "kernel_timeout_internal",
60    srcs = ["internal/kernel_timeout.cc"],
61    hdrs = ["internal/kernel_timeout.h"],
62    copts = ABSL_DEFAULT_COPTS,
63    linkopts = ABSL_DEFAULT_LINKOPTS,
64    visibility = [
65    ],
66    deps = [
67        "//absl/base",
68        "//absl/base:config",
69        "//absl/base:core_headers",
70        "//absl/base:raw_logging_internal",
71        "//absl/time",
72    ],
73)
74
75cc_test(
76    name = "kernel_timeout_internal_test",
77    srcs = ["internal/kernel_timeout_test.cc"],
78    copts = ABSL_TEST_COPTS,
79    flaky = 1,
80    linkopts = ABSL_DEFAULT_LINKOPTS,
81    deps = [
82        ":kernel_timeout_internal",
83        "//absl/base:config",
84        "//absl/random",
85        "//absl/time",
86        "@com_google_googletest//:gtest",
87        "@com_google_googletest//:gtest_main",
88    ],
89)
90
91cc_library(
92    name = "synchronization",
93    srcs = [
94        "barrier.cc",
95        "blocking_counter.cc",
96        "internal/create_thread_identity.cc",
97        "internal/futex_waiter.cc",
98        "internal/per_thread_sem.cc",
99        "internal/pthread_waiter.cc",
100        "internal/sem_waiter.cc",
101        "internal/stdcpp_waiter.cc",
102        "internal/waiter_base.cc",
103        "internal/win32_waiter.cc",
104        "mutex.cc",
105        "notification.cc",
106    ],
107    hdrs = [
108        "barrier.h",
109        "blocking_counter.h",
110        "internal/create_thread_identity.h",
111        "internal/futex.h",
112        "internal/futex_waiter.h",
113        "internal/per_thread_sem.h",
114        "internal/pthread_waiter.h",
115        "internal/sem_waiter.h",
116        "internal/stdcpp_waiter.h",
117        "internal/waiter.h",
118        "internal/waiter_base.h",
119        "internal/win32_waiter.h",
120        "mutex.h",
121        "notification.h",
122    ],
123    copts = ABSL_DEFAULT_COPTS,
124    linkopts = select({
125        "//absl:msvc_compiler": [],
126        "//absl:clang-cl_compiler": [],
127        "//absl:wasm": [],
128        "//conditions:default": ["-pthread"],
129    }) + ABSL_DEFAULT_LINKOPTS,
130    visibility = ["//visibility:public"],
131    deps = [
132        ":graphcycles_internal",
133        ":kernel_timeout_internal",
134        "//absl/base",
135        "//absl/base:atomic_hook",
136        "//absl/base:base_internal",
137        "//absl/base:config",
138        "//absl/base:core_headers",
139        "//absl/base:dynamic_annotations",
140        "//absl/base:malloc_internal",
141        "//absl/base:raw_logging_internal",
142        "//absl/debugging:stacktrace",
143        "//absl/debugging:symbolize",
144        "//absl/time",
145    ] + select({
146        "//conditions:default": [],
147    }),
148)
149
150cc_test(
151    name = "barrier_test",
152    size = "small",
153    srcs = ["barrier_test.cc"],
154    copts = ABSL_TEST_COPTS,
155    linkopts = ABSL_DEFAULT_LINKOPTS,
156    tags = [
157        "no_test_wasm",  # b/122473323
158    ],
159    deps = [
160        ":synchronization",
161        "//absl/time",
162        "@com_google_googletest//:gtest",
163        "@com_google_googletest//:gtest_main",
164    ],
165)
166
167cc_test(
168    name = "blocking_counter_test",
169    size = "small",
170    srcs = ["blocking_counter_test.cc"],
171    copts = ABSL_TEST_COPTS,
172    linkopts = ABSL_DEFAULT_LINKOPTS,
173    tags = [
174        "no_test_wasm",  # b/122473323
175    ],
176    deps = [
177        ":synchronization",
178        "//absl/time",
179        "@com_google_googletest//:gtest",
180        "@com_google_googletest//:gtest_main",
181    ],
182)
183
184cc_binary(
185    name = "blocking_counter_benchmark",
186    testonly = 1,
187    srcs = ["blocking_counter_benchmark.cc"],
188    copts = ABSL_TEST_COPTS,
189    linkopts = ABSL_DEFAULT_LINKOPTS,
190    tags = ["benchmark"],
191    deps = [
192        ":synchronization",
193        ":thread_pool",
194        "@com_github_google_benchmark//:benchmark_main",
195    ],
196)
197
198cc_test(
199    name = "graphcycles_test",
200    size = "medium",
201    srcs = ["internal/graphcycles_test.cc"],
202    copts = ABSL_TEST_COPTS,
203    linkopts = ABSL_DEFAULT_LINKOPTS,
204    deps = [
205        ":graphcycles_internal",
206        "//absl/base:core_headers",
207        "//absl/log",
208        "//absl/log:check",
209        "@com_google_googletest//:gtest",
210        "@com_google_googletest//:gtest_main",
211    ],
212)
213
214cc_test(
215    name = "graphcycles_benchmark",
216    srcs = ["internal/graphcycles_benchmark.cc"],
217    copts = ABSL_TEST_COPTS,
218    linkopts = ABSL_DEFAULT_LINKOPTS,
219    tags = [
220        "benchmark",
221    ],
222    deps = [
223        ":graphcycles_internal",
224        "//absl/base:raw_logging_internal",
225        "@com_github_google_benchmark//:benchmark_main",
226        "@com_google_googletest//:gtest",
227    ],
228)
229
230cc_library(
231    name = "thread_pool",
232    testonly = 1,
233    hdrs = ["internal/thread_pool.h"],
234    linkopts = ABSL_DEFAULT_LINKOPTS,
235    visibility = [
236        "//absl:__subpackages__",
237    ],
238    deps = [
239        ":synchronization",
240        "//absl/base:core_headers",
241        "//absl/functional:any_invocable",
242    ],
243)
244
245cc_test(
246    name = "mutex_test",
247    size = "large",
248    srcs = ["mutex_test.cc"],
249    copts = ABSL_TEST_COPTS,
250    flaky = 1,
251    linkopts = ABSL_DEFAULT_LINKOPTS,
252    shard_count = 25,
253    deps = [
254        ":synchronization",
255        ":thread_pool",
256        "//absl/base",
257        "//absl/base:config",
258        "//absl/base:core_headers",
259        "//absl/log",
260        "//absl/log:check",
261        "//absl/memory",
262        "//absl/time",
263        "@com_google_googletest//:gtest",
264        "@com_google_googletest//:gtest_main",
265    ],
266)
267
268cc_test(
269    name = "mutex_method_pointer_test",
270    srcs = ["mutex_method_pointer_test.cc"],
271    copts = ABSL_TEST_COPTS,
272    linkopts = ABSL_DEFAULT_LINKOPTS,
273    deps = [
274        ":synchronization",
275        "//absl/base:config",
276        "@com_google_googletest//:gtest",
277        "@com_google_googletest//:gtest_main",
278    ],
279)
280
281cc_library(
282    name = "mutex_benchmark_common",
283    testonly = 1,
284    srcs = ["mutex_benchmark.cc"],
285    copts = ABSL_TEST_COPTS,
286    linkopts = ABSL_DEFAULT_LINKOPTS,
287    visibility = [
288    ],
289    deps = [
290        ":synchronization",
291        ":thread_pool",
292        "//absl/base",
293        "//absl/base:config",
294        "@com_github_google_benchmark//:benchmark_main",
295    ],
296    alwayslink = 1,
297)
298
299cc_binary(
300    name = "mutex_benchmark",
301    testonly = 1,
302    copts = ABSL_DEFAULT_COPTS,
303    linkopts = ABSL_DEFAULT_LINKOPTS,
304    deps = [
305        ":mutex_benchmark_common",
306    ],
307)
308
309cc_test(
310    name = "notification_test",
311    size = "small",
312    srcs = ["notification_test.cc"],
313    copts = ABSL_TEST_COPTS,
314    flaky = 1,
315    linkopts = ABSL_DEFAULT_LINKOPTS,
316    tags = ["no_test_lexan"],
317    deps = [
318        ":synchronization",
319        "//absl/time",
320        "@com_google_googletest//:gtest",
321        "@com_google_googletest//:gtest_main",
322    ],
323)
324
325cc_library(
326    name = "per_thread_sem_test_common",
327    testonly = 1,
328    srcs = ["internal/per_thread_sem_test.cc"],
329    copts = ABSL_TEST_COPTS,
330    linkopts = ABSL_DEFAULT_LINKOPTS,
331    visibility = [
332    ],
333    deps = [
334        ":synchronization",
335        "//absl/base",
336        "//absl/base:config",
337        "//absl/strings",
338        "//absl/time",
339        "@com_google_googletest//:gtest",
340    ],
341    alwayslink = 1,
342)
343
344cc_test(
345    name = "per_thread_sem_test",
346    size = "large",
347    copts = ABSL_TEST_COPTS,
348    linkopts = ABSL_DEFAULT_LINKOPTS,
349    tags = [
350        "no_test_wasm",
351    ],
352    deps = [
353        ":per_thread_sem_test_common",
354        ":synchronization",
355        "//absl/strings",
356        "//absl/time",
357        "@com_google_googletest//:gtest_main",
358    ],
359)
360
361cc_test(
362    name = "waiter_test",
363    srcs = ["internal/waiter_test.cc"],
364    copts = ABSL_TEST_COPTS,
365    flaky = 1,
366    linkopts = ABSL_DEFAULT_LINKOPTS,
367    deps = [
368        ":kernel_timeout_internal",
369        ":synchronization",
370        ":thread_pool",
371        "//absl/base:config",
372        "//absl/random",
373        "//absl/time",
374        "@com_google_googletest//:gtest",
375        "@com_google_googletest//:gtest_main",
376    ],
377)
378
379cc_test(
380    name = "lifetime_test",
381    srcs = [
382        "lifetime_test.cc",
383    ],
384    copts = ABSL_TEST_COPTS,
385    linkopts = ABSL_DEFAULT_LINKOPTS,
386    tags = [
387        "no_test_ios_x86_64",
388        "no_test_wasm",
389    ],
390    deps = [
391        ":synchronization",
392        "//absl/base:core_headers",
393        "//absl/log:check",
394    ],
395)
396