Skip to content

Commit

Permalink
Merge pull request libevent#34 from pprindeville/describe-user-events
Browse files Browse the repository at this point in the history
Add explanation of user-triggered events
  • Loading branch information
widgetii committed Dec 10, 2022
2 parents f27b4fa + 4ee3f4c commit 68b62c7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Ref4_event.txt
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,30 @@ event_base will receive signals.

The kqueue backend does not have this limitation.

Creating user-triggered events
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Sometimes it's useful to create events which can be activated and
run later, when all higher-priority events have completed. Any sort
of cleanup or garbage-collection would be such an event. See "Events
with priorities" for an explanation of setting a lowered priority.

A user-triggered event can be created as:

[code,C]
--------
struct event *user = event_new(evbase, -1, 0, user_cb, myhandle);
--------

Note that no event_add() is required. It is then 'fired' with:

[code,C]
--------
event_active(user, 0, 0);
--------

The 3rd parameter is not significant for non-signal events.

Setting up events without heap-allocation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit 68b62c7

Please sign in to comment.