PipeWire  0.3.66
thread-loop.h
Go to the documentation of this file.
1 /* PipeWire */
2 /* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3 /* SPDX-License-Identifier: MIT */
4 
5 #ifndef PIPEWIRE_THREAD_LOOP_H
6 #define PIPEWIRE_THREAD_LOOP_H
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #include <pipewire/loop.h>
13 
78 struct pw_thread_loop;
79 
81 struct pw_thread_loop_events {
82 #define PW_VERSION_THREAD_LOOP_EVENTS 0
83  uint32_t version;
84 
86  void (*destroy) (void *data);
87 };
88 
90 struct pw_thread_loop *
91 pw_thread_loop_new(const char *name, const struct spa_dict *props);
92 
95 struct pw_thread_loop *
96 pw_thread_loop_new_full(struct pw_loop *loop, const char *name, const struct spa_dict *props);
97 
99 void pw_thread_loop_destroy(struct pw_thread_loop *loop);
100 
103  struct spa_hook *listener,
104  const struct pw_thread_loop_events *events,
105  void *data);
106 
109 
112 
115 
118 
121 
124 
127 int pw_thread_loop_timed_wait(struct pw_thread_loop *loop, int wait_max_sec);
128 
131 int pw_thread_loop_get_time(struct pw_thread_loop *loop, struct timespec *abstime, int64_t timeout);
132 
136 int pw_thread_loop_timed_wait_full(struct pw_thread_loop *loop, const struct timespec *abstime);
137 
139 void pw_thread_loop_signal(struct pw_thread_loop *loop, bool wait_for_accept);
140 
143 
146 
151 #ifdef __cplusplus
152 }
153 #endif
154 
155 #endif /* PIPEWIRE_THREAD_LOOP_H */
void pw_thread_loop_unlock(struct pw_thread_loop *loop)
Unlock the loop.
Definition: thread-loop.c:319
int pw_thread_loop_start(struct pw_thread_loop *loop)
Start the thread loop.
Definition: thread-loop.c:254
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:374
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:208
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:156
void pw_thread_loop_destroy(struct pw_thread_loop *loop)
Destroy a thread loop.
Definition: thread-loop.c:185
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:218
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:395
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:433
void pw_thread_loop_stop(struct pw_thread_loop *loop)
Stop the thread loop.
Definition: thread-loop.c:287
void pw_thread_loop_lock(struct pw_thread_loop *loop)
Lock the loop.
Definition: thread-loop.c:307
bool pw_thread_loop_in_thread(struct pw_thread_loop *loop)
Check if inside the thread.
Definition: thread-loop.c:446
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:177
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:356
int pw_thread_loop_timed_wait_full(struct pw_thread_loop *loop, const struct timespec *abstime)
Release the lock and wait up to abstime until some thread calls pw_thread_loop_signal.
Definition: thread-loop.c:418
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:335
pipewire/loop.h
Definition: src/pipewire/loop.h:31
struct spa_loop * loop
wrapped loop
Definition: src/pipewire/loop.h:33
Thread loop events.
Definition: thread-loop.h:86
void(* destroy)(void *data)
the loop is destroyed
Definition: thread-loop.h:92
uint32_t version
Definition: thread-loop.h:89
Definition: utils/dict.h:39
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:331