libguac  1.6.0
flag.h
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #ifndef GUAC_FLAG_H
21 #define GUAC_FLAG_H
22 
23 #include "flag-types.h"
24 
25 #include <pthread.h>
26 
27 struct guac_flag {
28 
34  pthread_mutex_t value_mutex;
35 
39  pthread_cond_t value_changed;
40 
47  unsigned int value;
48 
49 };
50 
62 void guac_flag_init(guac_flag* event_flag);
63 
78 void guac_flag_destroy(guac_flag* event_flag);
79 
98 void guac_flag_set(guac_flag* event_flag,
99  unsigned int flags);
100 
120 void guac_flag_set_and_lock(guac_flag* event_flag,
121  unsigned int flags);
122 
142 void guac_flag_clear(guac_flag* event_flag,
143  unsigned int flags);
144 
165 void guac_flag_clear_and_lock(guac_flag* event_flag,
166  unsigned int flags);
167 
182 void guac_flag_lock(guac_flag* event_flag);
183 
196 void guac_flag_unlock(guac_flag* event_flag);
197 
211 void guac_flag_wait_and_lock(guac_flag* event_flag,
212  unsigned int flags);
213 
240 int guac_flag_timedwait_and_lock(guac_flag* event_flag,
241  unsigned int flags, unsigned int msec_timeout);
242 
243 #endif
244 
pthread_mutex_t value_mutex
The mutex used to ensure concurrent changes to the value of this flag are threadsafe, as well as to satisfy the requirements of the pthread conditional used to signal changes to the value of this flag.
Definition: flag.h:34
unsigned int value
The current value of this flag.
Definition: flag.h:47
pthread_cond_t value_changed
Condition variable that signals when the value of this flag has changed.
Definition: flag.h:39
Generic integer flag intended for signalling of arbitrary events between processes.
Definition: flag.h:27