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_EventLoopagar low-level event loop

#include <agar/core.h>

The AG_EventLoop routine loops, continually checking for low-level events and processing them. Its operation is governed by a registered set of which determine the type of low-level events to monitor, and the procedures to invoke in order to handle 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.

Concurrent instances of () are allowed in multithreaded builds. In threaded builds, event sinks are associated with running thread at the time of creation (in thread-local storage).

int
AG_EventLoop(void);


void
(int exitCode);


void
(AG_Event *event);

() blocks the current thread, waiting for low-level events, and processing them until termination is requested. Its operation is governed by the registered set of event sinks.

The () 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_EventSink *sink);


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


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


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


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


void
(AG_EventSink *sink);


void
(AG_EventSink *sink);


void
(AG_EventSink *sink);

The () 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 occurred 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 occurred on the monitored process ident. The type of event is specified in flags (see PROCESS EVENTS below).

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

The () 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 () 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.
The file was written to.
The file was 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).

The AG_FileDlg(3) widget uses AG_SINK_FSEVENT to auto-refresh directory listings on platforms that offer filesystem monitoring capabilitie

The AG_ConsoleOpenFile(3) feature of AG_Console(3) sets up an event sink of type AG_SINK_READ to monitor changes on a file or stream.

The agardb(1) debugger uses AG_SINK_PROCEVENT to monitor events related to processes being debugged.

Agar's X11 driver AG_DriverGLX(3) sets up an event sink of type AG_SINK_READ in order to receive events from the X file descriptor:

Display *display;

static int
EventSink(AG_EventSink *es, AG_Event *event)
{
	Display *dpy = AG_PTR(1);

	while (XPending(dpy)) { /* Process event */ }
}

AG_AddEventSink(AG_SINK_READ,
    XConnectionNumber(display), 0,
    EventSink, "%p", display);

AG_CustomEventLoop(3), AG_Event(3), AG_Intro(3), poll(2), select(2), kqueue(2)

The AG_EventLoop call first appeared in Agar 1.0. Event sinks first appeared in Agar 1.5.0.

December 21, 2022 Agar 1.7

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.