deimos.event2.thread

@file event2/thread.h

Functions for multi-threaded applications using Libevent.

When using a multi-threaded application in which multiple threads add and delete events from a single event base, Libevent needs to lock its data structures.

Like the memory-management function hooks, all of the threading functions _must_ be set up before an event_base is created if you want the base to use them.

Most programs will either be using Windows threads or Posix threads. You can configure Libevent to use one of these event_use_windows_threads() or event_use_pthreads() respectively. If you're using another threading library, you'll need to configure threading functions manually using evthread_set_lock_callbacks() and evthread_set_condition_callbacks().

Members

Functions

evthread_enable_lock_debuging
void evthread_enable_lock_debuging()

Enable debugging wrappers around the current lock callbacks. If Libevent makes one of several common locking errors, exit with an assertion failure.

evthread_make_base_notifiable
int evthread_make_base_notifiable(event_base* base)

Make sure it's safe to tell an event base to wake up from another thread or a signal handler.

evthread_set_condition_callbacks
int evthread_set_condition_callbacks(const(evthread_condition_callbacks)* )

Sets a group of functions that Libevent should use for condition variables. For full information on the required callback API, see the documentation for the individual members of evthread_condition_callbacks.

evthread_set_id_callback
void evthread_set_id_callback(ExternC!(c_ulong function()) id_fn)

Sets the function for determining the thread id.

evthread_set_lock_callbacks
int evthread_set_lock_callbacks(const(evthread_lock_callbacks)* )

Sets a group of functions that Libevent should use for locking. For full information on the required callback API, see the documentation for the individual members of evthread_lock_callbacks.

evthread_use_pthreads
int evthread_use_pthreads()

Sets up Libevent for use with Pthreads locking and thread ID functions. Unavailable if Libevent is not build for use with pthreads. Requires libraries to link against Libevent_pthreads as well as Libevent.

evthread_use_windows_threads
int evthread_use_windows_threads()

Sets up Libevent for use with Windows builtin locking and thread ID functions. Unavailable if Libevent is not built for Windows.

Manifest constants

EVTHREAD_CONDITION_API_VERSION
enum EVTHREAD_CONDITION_API_VERSION;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
EVTHREAD_LOCKTYPE_READWRITE
enum EVTHREAD_LOCKTYPE_READWRITE;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
EVTHREAD_LOCKTYPE_RECURSIVE
enum EVTHREAD_LOCKTYPE_RECURSIVE;

A recursive lock is one that can be acquired multiple times at once by the * same thread. No other process can allocate the lock until the thread that * has been holding it has unlocked it as many times as it locked it.

EVTHREAD_LOCK_API_VERSION
enum EVTHREAD_LOCK_API_VERSION;

@}

EVTHREAD_READ
enum EVTHREAD_READ;

A flag passed to a locking callback when the lock was allocated as a * read-write lock, and we want to acquire or release the lock for reading.

EVTHREAD_TRY
enum EVTHREAD_TRY;

A flag passed to a locking callback when we don't want to block waiting * for the lock; if we can't get the lock immediately, we will instead * return nonzero from the locking callback.

EVTHREAD_USE_PTHREADS_IMPLEMENTED
enum EVTHREAD_USE_PTHREADS_IMPLEMENTED;

Defined if Libevent was built with support for evthread_use_pthreads()

EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED
enum EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED;

Defined if Libevent was built with support for evthread_use_windows_threads()

EVTHREAD_WRITE
enum EVTHREAD_WRITE;

A flag passed to a locking callback when the lock was allocated as a * read-write lock, and we want to acquire or release the lock for writing.

Structs

evthread_condition_callbacks
struct evthread_condition_callbacks

This structure describes the interface a threading library uses for condition variables. It's used to tell evthread_set_condition_callbacks how to use locking on this platform.

evthread_lock_callbacks
struct evthread_lock_callbacks

This structure describes the interface a threading library uses for locking. It's used to tell evthread_set_lock_callbacks() how to use locking on this platform.

Meta