The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

SYNOPSIS

This is an advanced feature of Event.

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 (v9)

 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);

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

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

  /* HOOKS */
  pe_qcallback *(*add_hook)(char *which, void *cb, void *ext_data);
  void (*cancel_hook)(pe_qcallback *qcb);

 };

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);

BUT I NEED A NEW TYPE OF WATCHER FOR MY INTERGALACTIC INFEROMETER

I'd prefer not to export the entire Event.h apparatus in favour of minimizing interdependencies. If you really, really need to create a new type of watcher send your problem analysis to the mailing list.