Commit a0e3ed89 authored by Mike Hibler's avatar Mike Hibler

Add polling interface to events.

parent 9051db8a
......@@ -8,7 +8,7 @@ SUBDIR = event
include $(OBJDIR)/Makeconf
SUBDIRS = lib sched tbgen example
SUBDIRS = lib sched tbgen example trafgen
all: $(SUBDIRS)
......@@ -26,6 +26,9 @@ tbgen:
example:
@$(MAKE) -C example all
trafgen:
@$(MAKE) -C trafgen all
install:
@$(MAKE) -C lib install
@$(MAKE) -C sched install
......@@ -38,6 +41,7 @@ subdir-clean:
@$(MAKE) -C sched clean
@$(MAKE) -C tbgen clean
@$(MAKE) -C example clean
@$(MAKE) -C trafgen clean
distclean: subdir-distclean
......@@ -46,6 +50,7 @@ subdir-distclean:
@$(MAKE) -C sched distclean
@$(MAKE) -C tbgen distclean
@$(MAKE) -C example distclean
@$(MAKE) -C trafgen distclean
.PHONY: $(SUBDIRS)
......@@ -172,6 +172,33 @@ event_unregister(event_handle_t handle)
}
/*
*
*/
int
event_poll(event_handle_t handle)
{
extern int depth;
int rv;
if (!handle->mainloop) {
ERROR("multithreaded programs cannot use event_poll\n");
return 0;
}
depth++;
rv = elvin_sync_default_select_and_dispatch(0, handle->status);
depth--;
if (rv == 0) {
ERROR("Elvin select_and_dispatch failed\n");
elvin_error_fprintf(stderr, handle->status);
}
return elvin_error_get_code(handle->status);
}
/*
* Enter the main loop of the event system, waiting to receive event
* notifications. Returns non-zero if the operation is successful, 0
......
......@@ -5,7 +5,7 @@
*
* @COPYRIGHT@
*
* $Id: event.h,v 1.8 2002-02-26 21:59:00 stoller Exp $
* $Id: event.h,v 1.9 2002-02-28 00:16:18 mike Exp $
*/
#ifndef __EVENT_H__
......@@ -61,6 +61,7 @@ typedef struct {
#define ADDRESSTUPLE_ANY NULL
#define ADDRESSTUPLE_ALL "*"
#define OBJECTTYPE_TESTBED "TBCONTROL"
#define OBJECTTYPE_TRAFGEN "TRAFGEN"
address_tuple_t address_tuple_alloc(void);
int address_tuple_free(address_tuple_t);
......@@ -127,6 +128,7 @@ typedef void (*event_notify_callback_t)(event_handle_t handle,
/* event.c */
event_handle_t event_register(char *name, int threaded);
int event_unregister(event_handle_t handle);
int event_poll(event_handle_t handle);
int event_main(event_handle_t handle);
int event_notify(event_handle_t handle, event_notification_t notification);
int event_schedule(event_handle_t handle, event_notification_t notification,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment