From d0f5be023ca266a09682041b9f2a9d697332d8f8 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Wed, 5 Mar 2008 12:01:37 +0000 Subject: [PATCH] Restore r17703; it was accidentally removed as part of r17704. This commit was SVN r17728. The following SVN revision numbers were found above: r17703 --> open-mpi/ompi@1bedaea79b14ad0e80aa01476d60b6febecb23ca r17704 --> open-mpi/ompi@8189fcc7d5f34b9cec6cb05aadbcff6b4fbb7134 --- orte/runtime/orte_wait.c | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/orte/runtime/orte_wait.c b/orte/runtime/orte_wait.c index 9515b38520..4bbb849ef7 100644 --- a/orte/runtime/orte_wait.c +++ b/orte/runtime/orte_wait.c @@ -695,6 +695,31 @@ internal_waitpid_callback(int fd, short event, void *arg) #elif defined(__WINDOWS__) +static volatile int cb_enabled = true; +static opal_mutex_t mutex; +static opal_list_t pending_pids; +static opal_list_t registered_cb; + + +/********************************************************************* +* +* Wait Object Declarations +* +********************************************************************/ +static void message_event_destructor(orte_message_event_t *ev) +{ + OBJ_RELEASE(ev->buffer); +} + +static void message_event_constructor(orte_message_event_t *ev) +{ + ev->buffer = OBJ_NEW(opal_buffer_t); +} +OBJ_CLASS_INSTANCE(orte_message_event_t, + opal_object_t, + message_event_constructor, + message_event_destructor); + typedef struct { opal_list_item_t super; pid_t pid; @@ -762,6 +787,15 @@ orte_wait_finalize(void) return ORTE_SUCCESS; } +void orte_trigger_event(int trig) +{ + int data=1; + + write(trig, &data, sizeof(int)); + opal_progress(); +} + + /** * Internal function which find a corresponding process structure * based on the pid. If create is true and the pid does not have a @@ -954,6 +988,34 @@ orte_wait_cb_enable(void) return ORTE_SUCCESS; } + +int orte_wait_event(opal_event_t **event, int *trig, + void (*cbfunc)(int, short, void*)) +{ + int p[2]; + + if (pipe(p) < 0) { + ORTE_ERROR_LOG(ORTE_ERR_SYS_LIMITS_PIPES); + return ORTE_ERR_SYS_LIMITS_PIPES; + } + + /* create the event */ + *event = (opal_event_t*)malloc(sizeof(opal_event_t)); + + /* pass back the write end of the pipe */ + *trig = p[1]; + + /* define the event to fire when someone writes to the pipe */ + opal_event_set(*event, p[0], OPAL_EV_READ, cbfunc, NULL); + + /* Add it to the active events, without a timeout */ + opal_event_add(*event, NULL); + + /* all done */ + return ORTE_SUCCESS; +} + + int orte_wait_kill(int sig) {