1/* Copyright 2016 Google Inc.
2
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License. */
14
15#ifndef NSYNC_INTERNAL_WAIT_INTERNAL_H_
16#define NSYNC_INTERNAL_WAIT_INTERNAL_H_
17
18NSYNC_CPP_START_
19
20/* Implementations of "struct nsync_waitable_s" must provide functions in struct
21 nsync_waitable_funcs_s (see public/nsync_wait.h). When nsync_wait_n() waits
22 on a client's object, those functions are called with v pointing to the
23 client's object and nw pointing to a struct nsync_waiter_s. */
24struct nsync_waiter_s {
25 uint32_t tag; /* used for debugging */
26 nsync_dll_element_ q; /* used to link children of parent */
27 nsync_atomic_uint32_ waiting; /* non-zero <=> the waiter is waiting */
28 struct nsync_semaphore_s_ *sem; /* *sem will be Ved when waiter is woken */
29 uint32_t flags; /* see below */
30};
31
32#define NSYNC_WAITER_FLAG_MUCV 0x1 /* set if waiter is embedded in Mu/CV's internal structures */
33
34NSYNC_CPP_END_
35
36#endif /*NSYNC_INTERNAL_WAIT_INTERNAL_H_*/
37