Commit 7bc62935 authored by Shane Snyder's avatar Shane Snyder

reorg margo timers using internal header file

parent acef4b65
...@@ -15,7 +15,7 @@ CLEANFILES = $(bin_SCRIPTS) ...@@ -15,7 +15,7 @@ CLEANFILES = $(bin_SCRIPTS)
MAINTAINERCLEANFILES = MAINTAINERCLEANFILES =
EXTRA_DIST = EXTRA_DIST =
BUILT_SOURCES = BUILT_SOURCES =
include_HEADERS = include/margo.h include/margo-timer.h include_HEADERS = include/margo.h
EXTRA_DIST += \ EXTRA_DIST += \
prepare.sh prepare.sh
......
...@@ -17,8 +17,6 @@ extern "C" { ...@@ -17,8 +17,6 @@ extern "C" {
#include <abt.h> #include <abt.h>
#include <ev.h> #include <ev.h>
#include "margo-timer.h"
struct margo_instance; struct margo_instance;
typedef struct margo_instance* margo_instance_id; typedef struct margo_instance* margo_instance_id;
...@@ -156,6 +154,13 @@ hg_return_t margo_addr_lookup( ...@@ -156,6 +154,13 @@ hg_return_t margo_addr_lookup(
const char *name, const char *name,
hg_addr_t *addr); hg_addr_t *addr);
/**
* Suspends the calling ULT for a specified time duration
* @param [in] timeout_ms timeout duration in milliseconds
*/
void margo_thread_sleep(
double timeout_ms);
/** /**
* Retrive the Margo instance that has been associated with a Mercury class * Retrive the Margo instance that has been associated with a Mercury class
* @param [in] cl Mercury class * @param [in] cl Mercury class
......
src_libmargo_a_SOURCES += \ src_libmargo_a_SOURCES += \
src/margo.c \ src/margo.c \
src/margo-timer.h \
src/margo-timer.c src/margo-timer.c
...@@ -49,47 +49,6 @@ void margo_timer_sys_shutdown() ...@@ -49,47 +49,6 @@ void margo_timer_sys_shutdown()
return; return;
} }
typedef struct
{
ABT_mutex mutex;
ABT_cond cond;
} margo_thread_sleep_cb_dat;
static void margo_thread_sleep_cb(void *arg)
{
margo_thread_sleep_cb_dat *sleep_cb_dat =
(margo_thread_sleep_cb_dat *)arg;
/* wake up the sleeping thread */
ABT_mutex_lock(sleep_cb_dat->mutex);
ABT_cond_signal(sleep_cb_dat->cond);
ABT_mutex_unlock(sleep_cb_dat->mutex);
return;
}
void margo_thread_sleep(
double timeout_ms)
{
margo_timer_t sleep_timer;
margo_thread_sleep_cb_dat sleep_cb_dat;
/* set data needed for sleep callback */
ABT_mutex_create(&(sleep_cb_dat.mutex));
ABT_cond_create(&(sleep_cb_dat.cond));
/* initialize the sleep timer */
margo_timer_init(&sleep_timer, margo_thread_sleep_cb,
&sleep_cb_dat, timeout_ms);
/* yield thread for specified timeout */
ABT_mutex_lock(sleep_cb_dat.mutex);
ABT_cond_wait(sleep_cb_dat.cond, sleep_cb_dat.mutex);
ABT_mutex_unlock(sleep_cb_dat.mutex);
return;
}
void margo_timer_init( void margo_timer_init(
margo_timer_t *timer, margo_timer_t *timer,
margo_timer_cb_fn cb_fn, margo_timer_cb_fn cb_fn,
......
...@@ -34,13 +34,6 @@ void margo_timer_sys_init( ...@@ -34,13 +34,6 @@ void margo_timer_sys_init(
void margo_timer_sys_shutdown( void margo_timer_sys_shutdown(
void); void);
/**
* Suspends the calling ULT for a specified time duration
* @param [in] timeout_ms timeout duration in milliseconds
*/
void margo_thread_sleep(
double timeout_ms);
/** /**
* Initializes a margo timer object which will perform some action * Initializes a margo timer object which will perform some action
* after a specified time duration * after a specified time duration
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <math.h> #include <math.h>
#include "margo.h" #include "margo.h"
#include "margo-timer.h"
#include "utlist.h" #include "utlist.h"
/* TODO: including core.h for cancel definition, presumably this will be /* TODO: including core.h for cancel definition, presumably this will be
...@@ -455,6 +456,48 @@ hg_return_t margo_bulk_transfer( ...@@ -455,6 +456,48 @@ hg_return_t margo_bulk_transfer(
return(hret); return(hret);
} }
typedef struct
{
ABT_mutex mutex;
ABT_cond cond;
} margo_thread_sleep_cb_dat;
static void margo_thread_sleep_cb(void *arg)
{
margo_thread_sleep_cb_dat *sleep_cb_dat =
(margo_thread_sleep_cb_dat *)arg;
/* wake up the sleeping thread */
ABT_mutex_lock(sleep_cb_dat->mutex);
ABT_cond_signal(sleep_cb_dat->cond);
ABT_mutex_unlock(sleep_cb_dat->mutex);
return;
}
void margo_thread_sleep(
double timeout_ms)
{
margo_timer_t sleep_timer;
margo_thread_sleep_cb_dat sleep_cb_dat;
/* set data needed for sleep callback */
ABT_mutex_create(&(sleep_cb_dat.mutex));
ABT_cond_create(&(sleep_cb_dat.cond));
/* initialize the sleep timer */
margo_timer_init(&sleep_timer, margo_thread_sleep_cb,
&sleep_cb_dat, timeout_ms);
/* yield thread for specified timeout */
ABT_mutex_lock(sleep_cb_dat.mutex);
ABT_cond_wait(sleep_cb_dat.cond, sleep_cb_dat.mutex);
ABT_mutex_unlock(sleep_cb_dat.mutex);
return;
}
margo_instance_id margo_hg_class_to_instance(hg_class_t *cl) margo_instance_id margo_hg_class_to_instance(hg_class_t *cl)
{ {
int i; int i;
......
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