NAME

Event::MakeMaker - MakeMaker glue for the C-level Event API

SYNOPSIS

This is an advanced feature.

DESCRIPTION

If you need optimal performance, you can hook into Event at the C-level. You'll need to make changes to your Makefile.PL and add code to your xs or c file(s).

WARNING

When you hook in at the C-level, you get a huge performance gain but you reduce the chances that your code will work unmodified with newer versions of perl or Event. This may or not be a problem. Just be aware of it and set your expectations accordingly.

HOW TO

Makefile.PL

use Event::MakeMaker qw(event_args);

# ... set up %args ...

WriteMakefile(event_args(%args));

XS

#include "EventAPI.h"
static struct EventAPI *Ev=0;

BOOT:
  FETCH_EVENT_API("YourModule", Ev);

API (v8)

struct EventAPI {

 /* EVENTS */
 void (*start)(pe_event *ev, int repeat);
 void (*queue)(pe_event *ev, int count);
 void (*now)(pe_event *ev);
 void (*suspend)(pe_event *ev);
 void (*resume)(pe_event *ev);
 void (*cancel)(pe_event *ev);

 /* TIMEABLE */
 void (*tstart)(pe_timeable *);
 void (*tstop)(pe_timeable *);

 pe_idle     *(*new_idle)();
 pe_timer    *(*new_timer)();
 pe_io       *(*new_io)();
 pe_var      *(*new_var)();
 pe_signal   *(*new_signal)();

};

EXAMPLE

static pe_io *X11_ev=0;

static void x_server_dispatch(void *ext_data)
{ ... }

if (!X11_ev) {
  X11_ev = Ev->new_io();
  X11_ev->events = PE_R;
  sv_setpv(X11_ev->base.desc, "X::Server");
  X11_ev->base.callback = (void*) x_server_dispatch;
  X11_ev->base.ext_data = <whatever>;
  X11_ev->base.priority = PE_PRIO_NORMAL;
}
X11_ev->fd = x_fd;
Ev->resume((pe_event*) X11_ev);
Ev->start((pe_event*) X11_ev, 0);