PipeWire  0.3.61
thread-loop.h
Go to the documentation of this file.
1 /* PipeWire
2  *
3  * Copyright © 2018 Wim Taymans
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef PIPEWIRE_THREAD_LOOP_H
26 #define PIPEWIRE_THREAD_LOOP_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <pipewire/loop.h>
33 
98 struct pw_thread_loop;
99 
101 struct pw_thread_loop_events {
102 #define PW_VERSION_THREAD_LOOP_EVENTS 0
103  uint32_t version;
104 
106  void (*destroy) (void *data);
107 };
108 
110 struct pw_thread_loop *
111 pw_thread_loop_new(const char *name, const struct spa_dict *props);
112 
115 struct pw_thread_loop *
116 pw_thread_loop_new_full(struct pw_loop *loop, const char *name, const struct spa_dict *props);
117 
119 void pw_thread_loop_destroy(struct pw_thread_loop *loop);
120 
123  struct spa_hook *listener,
124  const struct pw_thread_loop_events *events,
125  void *data);
126 
129 
132 
135 
138 
141 
144 
147 int pw_thread_loop_timed_wait(struct pw_thread_loop *loop, int wait_max_sec);
148 
151 int pw_thread_loop_get_time(struct pw_thread_loop *loop, struct timespec *abstime, int64_t timeout);
152 
156 int pw_thread_loop_timed_wait_full(struct pw_thread_loop *loop, struct timespec *abstime);
157 
159 void pw_thread_loop_signal(struct pw_thread_loop *loop, bool wait_for_accept);
160 
163 
166 
171 #ifdef __cplusplus
172 }
173 #endif
174 
175 #endif /* PIPEWIRE_THREAD_LOOP_H */
void pw_thread_loop_unlock(struct pw_thread_loop *loop)
Unlock the loop.
Definition: thread-loop.c:339
int pw_thread_loop_start(struct pw_thread_loop *loop)
Start the thread loop.
Definition: thread-loop.c:274
int pw_thread_loop_timed_wait(struct pw_thread_loop *loop, int wait_max_sec)
Release the lock and wait a maximum of 'wait_max_sec' seconds until some thread calls pw_thread_loop_...
Definition: thread-loop.c:394
void pw_thread_loop_add_listener(struct pw_thread_loop *loop, struct spa_hook *listener, const struct pw_thread_loop_events *events, void *data)
Add an event listener.
Definition: thread-loop.c:228
struct pw_thread_loop * pw_thread_loop_new(const char *name, const struct spa_dict *props)
Make a new thread loop with the given name and optional properties.
Definition: thread-loop.c:176
void pw_thread_loop_destroy(struct pw_thread_loop *loop)
Destroy a thread loop.
Definition: thread-loop.c:205
struct pw_loop * pw_thread_loop_get_loop(struct pw_thread_loop *loop)
Get the loop implementation of the thread loop.
Definition: thread-loop.c:238
int pw_thread_loop_get_time(struct pw_thread_loop *loop, struct timespec *abstime, int64_t timeout)
Get a struct timespec suitable for pw_thread_loop_timed_wait_full.
Definition: thread-loop.c:415
void pw_thread_loop_accept(struct pw_thread_loop *loop)
Signal all threads executing pw_thread_loop_signal with wait_for_accept.
Definition: thread-loop.c:453
void pw_thread_loop_stop(struct pw_thread_loop *loop)
Stop the thread loop.
Definition: thread-loop.c:307
void pw_thread_loop_lock(struct pw_thread_loop *loop)
Lock the loop.
Definition: thread-loop.c:327
int pw_thread_loop_timed_wait_full(struct pw_thread_loop *loop, struct timespec *abstime)
Release the lock and wait up to abstime until some thread calls pw_thread_loop_signal.
Definition: thread-loop.c:438
bool pw_thread_loop_in_thread(struct pw_thread_loop *loop)
Check if inside the thread.
Definition: thread-loop.c:466
struct pw_thread_loop * pw_thread_loop_new_full(struct pw_loop *loop, const char *name, const struct spa_dict *props)
Make a new thread loop with the given loop, name and optional properties.
Definition: thread-loop.c:197
void pw_thread_loop_wait(struct pw_thread_loop *loop)
Release the lock and wait until some thread calls pw_thread_loop_signal.
Definition: thread-loop.c:376
void pw_thread_loop_signal(struct pw_thread_loop *loop, bool wait_for_accept)
Signal all threads waiting with pw_thread_loop_wait.
Definition: thread-loop.c:355
pipewire/loop.h
Definition: loop.h:51
struct spa_loop * loop
wrapped loop
Definition: loop.h:53
Thread loop events.
Definition: thread-loop.h:106
void(* destroy)(void *data)
the loop is destroyed
Definition: thread-loop.h:112
uint32_t version
Definition: thread-loop.h:109
Definition: dict.h:59
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:351