avahi  0.6.31
thread-watch.h File Reference

Threaded poll() based main loop implementation. More...

#include <sys/poll.h>
#include <avahi-common/cdecl.h>
#include <avahi-common/watch.h>

Go to the source code of this file.

Typedefs

typedef struct AvahiThreadedPoll AvahiThreadedPoll
 A main loop object that runs an AvahiSimplePoll in its own thread. More...
 

Functions

AvahiThreadedPollavahi_threaded_poll_new (void)
 Create a new event loop object. More...
 
void avahi_threaded_poll_free (AvahiThreadedPoll *p)
 Free an event loop object. More...
 
const AvahiPollavahi_threaded_poll_get (AvahiThreadedPoll *p)
 Return the abstracted poll API object for this event loop object. More...
 
int avahi_threaded_poll_start (AvahiThreadedPoll *p)
 Start the event loop helper thread. More...
 
int avahi_threaded_poll_stop (AvahiThreadedPoll *p)
 Request that the event loop quits and the associated thread stops. More...
 
void avahi_threaded_poll_quit (AvahiThreadedPoll *p)
 Request that the event loop quits and the associated thread stops. More...
 
void avahi_threaded_poll_lock (AvahiThreadedPoll *p)
 Lock the main loop object. More...
 
void avahi_threaded_poll_unlock (AvahiThreadedPoll *p)
 Unlock the event loop object, use this as counterpart to avahi_threaded_poll_lock() More...
 

Detailed Description

Threaded poll() based main loop implementation.

Definition in file thread-watch.h.

Typedef Documentation

A main loop object that runs an AvahiSimplePoll in its own thread.

Since
0.6.4

Definition at line 32 of file thread-watch.h.

Function Documentation

void avahi_threaded_poll_free ( AvahiThreadedPoll p)

Free an event loop object.

This will stop the associated event loop thread (if it is running).

Since
0.6.4
const AvahiPoll* avahi_threaded_poll_get ( AvahiThreadedPoll p)

Return the abstracted poll API object for this event loop object.

The will return the same pointer each time it is called.

Since
0.6.4
void avahi_threaded_poll_lock ( AvahiThreadedPoll p)

Lock the main loop object.

Use this if you want to access the event loop objects (such as creating a new event source) from anything else but the event loop helper thread, i.e. from anything else but event loop callbacks

Since
0.6.4
AvahiThreadedPoll* avahi_threaded_poll_new ( void  )

Create a new event loop object.

This will allocate the internal AvahiSimplePoll, but will not start the helper thread.

Since
0.6.4
void avahi_threaded_poll_quit ( AvahiThreadedPoll p)

Request that the event loop quits and the associated thread stops.

Call this from inside the helper thread if you want to shut it down.

Since
0.6.4
int avahi_threaded_poll_start ( AvahiThreadedPoll p)

Start the event loop helper thread.

After the thread has started you must make sure to access the event loop object (AvahiThreadedPoll, AvahiPoll and all its associated objects) synchronized, i.e. with proper locking. You may want to use avahi_threaded_poll_lock()/avahi_threaded_poll_unlock() for this, which will lock the the entire event loop. Please note that event loop callback functions are called from the event loop helper thread with that lock held, i.e. avahi_threaded_poll_lock() calls are not required from event callbacks.

Since
0.6.4
int avahi_threaded_poll_stop ( AvahiThreadedPoll p)

Request that the event loop quits and the associated thread stops.

Call this from outside the helper thread if you want to shut it down.

Since
0.6.4
void avahi_threaded_poll_unlock ( AvahiThreadedPoll p)

Unlock the event loop object, use this as counterpart to avahi_threaded_poll_lock()

Since
0.6.4