Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sds
margo
Commits
7bc62935
Commit
7bc62935
authored
Apr 18, 2016
by
Shane Snyder
Browse files
reorg margo timers using internal header file
parent
acef4b65
Changes
6
Hide whitespace changes
Inline
Side-by-side
Makefile.am
View file @
7bc62935
...
...
@@ -15,7 +15,7 @@ CLEANFILES = $(bin_SCRIPTS)
MAINTAINERCLEANFILES
=
EXTRA_DIST
=
BUILT_SOURCES
=
include_HEADERS
=
include/margo.h
include/margo-timer.h
include_HEADERS
=
include/margo.h
EXTRA_DIST
+=
\
prepare.sh
...
...
include/margo.h
View file @
7bc62935
...
...
@@ -17,8 +17,6 @@ extern "C" {
#include <abt.h>
#include <ev.h>
#include "margo-timer.h"
struct
margo_instance
;
typedef
struct
margo_instance
*
margo_instance_id
;
...
...
@@ -156,6 +154,13 @@ hg_return_t margo_addr_lookup(
const
char
*
name
,
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
* @param [in] cl Mercury class
...
...
src/Makefile.subdir
View file @
7bc62935
src_libmargo_a_SOURCES
+=
\
src/margo.c
\
src/margo-timer.h
\
src/margo-timer.c
src/margo-timer.c
View file @
7bc62935
...
...
@@ -49,47 +49,6 @@ void margo_timer_sys_shutdown()
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
(
margo_timer_t
*
timer
,
margo_timer_cb_fn
cb_fn
,
...
...
include
/margo-timer.h
→
src
/margo-timer.h
View file @
7bc62935
...
...
@@ -34,13 +34,6 @@ void margo_timer_sys_init(
void
margo_timer_sys_shutdown
(
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
* after a specified time duration
...
...
src/margo.c
View file @
7bc62935
...
...
@@ -14,6 +14,7 @@
#include <math.h>
#include "margo.h"
#include "margo-timer.h"
#include "utlist.h"
/* TODO: including core.h for cancel definition, presumably this will be
...
...
@@ -455,6 +456,48 @@ hg_return_t margo_bulk_transfer(
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
)
{
int
i
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment