PipeWire: pw_thread_loop Class Reference

PipeWire 0.1.9

Public Member Functions
pw_thread_loop Class Reference

PipeWire threaded loop object. More...

## Public Member Functions
struct pw_thread_loop * | pw_thread_loop_new (struct pw_loop *loop, const char *name)
| Create a new pw_thread_loop. More...
void | pw_thread_loop_destroy (struct pw_thread_loop *loop)
| Destroy a threaded loop. More...
int | pw_thread_loop_start (struct pw_thread_loop *loop)
| Start the thread to handle loop. More...
void | pw_thread_loop_stop (struct pw_thread_loop *loop)
| Quit the loop and stop its thread. More...
void | pw_thread_loop_lock (struct pw_thread_loop *loop)
| Lock the mutex associated with loop. More...
void | pw_thread_loop_unlock (struct pw_thread_loop *loop)
| Unlock the mutex associated with loop. More...
void | pw_thread_loop_signal (struct pw_thread_loop *loop, bool wait_for_accept)
| Signal the thread. More...
void | pw_thread_loop_wait (struct pw_thread_loop *loop)
| Wait for the loop thread to call pw_thread_loop_signal() More...
int | pw_thread_loop_timed_wait (struct pw_thread_loop *loop, int wait_max_sec)
| Wait for the loop thread to call pw_thread_loop_signal() or time out. More...
void | pw_thread_loop_accept (struct pw_thread_loop *loop)
| Signal the loop thread waiting for accept with pw_thread_loop_signal() More...
bool | pw_thread_loop_in_thread (struct pw_thread_loop *loop)
| Check if we are inside the thread of the loop. More...

## Detailed Description

PipeWire threaded loop object.

The threaded loop object runs a pw_loop in a separate thread and ensures proper locking is done.

All of the loop callbacks will be executed with the loop lock held.

See also Threaded Loop

## Member Function Documentation

## ◆ pw_thread_loop_accept()

void pw_thread_loop_accept | ( | struct pw_thread_loop * | loop | ) |

Signal the loop thread waiting for accept with pw_thread_loop_signal()

Parameters

  loop | a pw_thread_loop to signal

## ◆ pw_thread_loop_destroy()

void pw_thread_loop_destroy | ( | struct pw_thread_loop * | loop | ) |

Destroy a threaded loop.

References pw_thread_loop_stop().

## ◆ pw_thread_loop_in_thread()

bool pw_thread_loop_in_thread | ( | struct pw_thread_loop * | loop | ) |

Check if we are inside the thread of the loop.

Parameters

  loop | a pw_thread_loop to signal

Returns
  true when called inside the thread of loop.

## ◆ pw_thread_loop_lock()

void pw_thread_loop_lock | ( | struct pw_thread_loop * | loop | ) |

Lock the mutex associated with loop.

Parameters

  loop | a pw_thread_loop

## ◆ pw_thread_loop_new()

struct pw_thread_loop * pw_thread_loop_new | ( | struct pw_loop * | loop,
|  | const char * | name
| ) |  |

Create a new pw_thread_loop.

Parameters

  loop | the loop to wrap
  name | the name of the thread or NULL

Returns
  a newly allocated pw_thread_loop

Make a new pw_thread_loop that will run loop in a thread with name.

After this function you should probably call pw_thread_loop_start() to actually start the thread

References pw_log::pw_log_debug(), and pw_loop_add_hook.

## ◆ pw_thread_loop_signal()

void pw_thread_loop_signal | ( | struct pw_thread_loop * | loop,
|  | bool | wait_for_accept
| ) |  |

Signal the thread.

Parameters

  loop | a pw_thread_loop to signal
  wait_for_accept | if we need to wait for accept

Signal the thread of loop. If wait_for_accept is true, this function waits until pw_thread_loop_accept() is called.

## ◆ pw_thread_loop_start()

int pw_thread_loop_start | ( | struct pw_thread_loop * | loop | ) |

Start the thread to handle loop.

Parameters

  loop | a pw_thread_loop

Returns
  0 on success

## ◆ pw_thread_loop_stop()

void pw_thread_loop_stop | ( | struct pw_thread_loop * | loop | ) |

Quit the loop and stop its thread.

Parameters

  loop | a pw_thread_loop

References pw_log::pw_log_debug(), and pw_loop_signal_event.

Referenced by pw_thread_loop_destroy().

## ◆ pw_thread_loop_timed_wait()

int pw_thread_loop_timed_wait | ( | struct pw_thread_loop * | loop,
|  | int | wait_max_sec
| ) |  |

Wait for the loop thread to call pw_thread_loop_signal() or time out.

Parameters

  loop | a pw_thread_loop to signal
  wait_max_sec | the maximum number of seconds to wait for a pw_thread_loop_signal()

Returns
  0 on success or ETIMEDOUT on timeout

## ◆ pw_thread_loop_unlock()

void pw_thread_loop_unlock | ( | struct pw_thread_loop * | loop | ) |

Unlock the mutex associated with loop.

Parameters

  loop | a pw_thread_loop

## ◆ pw_thread_loop_wait()

void pw_thread_loop_wait | ( | struct pw_thread_loop * | loop | ) |

Wait for the loop thread to call pw_thread_loop_signal()

Parameters

  loop | a pw_thread_loop to signal

The documentation for this class was generated from the following files:

- thread-loop.h
- thread-loop.c