GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
AG_EVENTLOOP(3) FreeBSD Library Functions Manual AG_EVENTLOOP(3)

AG_EventLoop
agar low-level event loop

#include <agar/core.h>

The AG_EventLoop routine loops, continually checking for low-level events and processing them. The most common type of low-level events are:

  1. Activity on a socket or file descriptor.
  2. Expiration of a timer.
  3. Kernel-event notifications (e.g., kqueue(2) events). This includes filesystem events and process monitoring.

If thread support is available, Agar allows multiple instances of AG_EventLoop() running concurrently under different threads.

int
AG_EventLoop(void);


void
AG_Terminate(int exitCode);


void
AG_TerminateEv(AG_Event *event);

The AG_EventLoop() routine blocks the current thread, waiting for low-level events, and processing them. The operation of AG_EventLoop is governed by a set of thread-specific event sinks.

Agar-based libraries such as Agar-GUI will automatically register event sinks as appropriate upon initialization (for example, graphics drivers based on the X Windows system may set up an event sink of type AG_SINK_READ to monitor activity on the X file descriptor). Applications are free to register their own event sinks using AG_AddEventSink().

The AG_Terminate() function requests termination of the event loop associated with the current thread. If the current thread is the main thread, AG_Terminate() will terminate the application with exitCode as return code. The AG_TerminateEv() variant accepts an AG_Event style argument instead of an int for the exit code.

AG_EventSink *
AG_AddEventSink(enum ag_event_sink_type type, int ident, Uint flags, AG_EventSinkFn fn, const char *fnArgs);


void
AG_DelEventSink(AG_EventSink *sink);


void
AG_DelEventsSinkByIdent(enum ag_event_sink_type type, int ident, Uint flags);


AG_EventSink *
AG_AddEventPrologue(AG_EventSinkFn fn, const char *fnArgs, ...);


AG_EventSink *
AG_AddEventEpilogue(AG_EventSinkFn fn, const char *fnArgs, ...);


AG_EventSink *
AG_AddEventSpinner(AG_EventSinkFn fn, const char *fnArgs, ...);


void
AG_DelEventPrologue(AG_EventSink *sink);


void
AG_DelEventEpilogue(AG_EventSink *sink);


void
AG_DelEventSpinner(AG_EventSink *sink);

The
AG_AddEventSink(); routine creates a new event sink under the current thread, and returns a pointer to a newly-allocated
AG_EventSink structure. The type argument may be one of:

Data is available for reading on file referenced by ident.
Data is available for writing on file referenced by ident.
A filesystem event has occured on the file/directory referenced by ident. The type of event is specified in flags (see FILESYSTEM EVENTS for the accepted flags).
An event has occured on the monitored process ident. The type of event is specified in flags (see PROCESS EVENTS below).

The
AG_DelEventSink(); function destroys the specified event sink. The
AG_DelEventSinksByIdent(); function destroys all event sinks with matching ident and flags.

The
AG_AddEventPrologue(); function registers a callback routine to be invoked once at the start of
AG_EventLoop();.
AG_AddEventEpilogue(); registers a callback routine to be invoked on exit, before
AG_EventLoop(); returns.
AG_DelEventEpilogue(); and
AG_DelEventPrologue(); destroy the specified epilogue/prologue routine.

The
AG_AddEventSpinner(); routine registers a "spinner" callback routine. Spinner routines are invoked repeatedly and unconditionally by
AG_EventLoop();, until the event loop terminates, or
AG_DelEventSpinner(); is invoked.

Acceptable flags for the AG_SINK_FSEVENT event sink include:

The file has been deleted.
A write has occured on the file.
The file has been extended in size.
File attributes have been changed.
The link count on the file has changed.
The referenced file has been renamed.
Filesystem has unmount, or revoke(2) called.

Acceptable flags for the AG_SINK_PROCEVENT event sink include:

Monitored process has exited.
Monitored process has called fork(2).
Monitored process has called exec(3).

AG_CustomEventLoop(3), AG_Event(3), AG_Intro(3)

The AG_EventLoop call first appeared in Agar 1.0. Event sinks first appeared in Agar 1.5.0.
April 14, 2014 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.