Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
margo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
18
Issues
18
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
sds
margo
Commits
13a368f7
Commit
13a368f7
authored
Apr 19, 2016
by
Shane Snyder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
loop over sleep cond_wait for safety
parent
a280a0c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
src/margo.c
src/margo.c
+6
-1
No files found.
src/margo.c
View file @
13a368f7
...
...
@@ -211,6 +211,7 @@ static void hg_progress_fn(void* foo)
}
else
{
printf
(
"sleep
\n
"
);
HG_Progress
(
mid
->
hg_context
,
100
);
}
}
...
...
@@ -466,6 +467,7 @@ typedef struct
{
ABT_mutex
mutex
;
ABT_cond
cond
;
int
is_asleep
;
}
margo_thread_sleep_cb_dat
;
static
void
margo_thread_sleep_cb
(
void
*
arg
)
...
...
@@ -475,6 +477,7 @@ static void margo_thread_sleep_cb(void *arg)
/* wake up the sleeping thread */
ABT_mutex_lock
(
sleep_cb_dat
->
mutex
);
sleep_cb_dat
->
is_asleep
=
0
;
ABT_cond_signal
(
sleep_cb_dat
->
cond
);
ABT_mutex_unlock
(
sleep_cb_dat
->
mutex
);
...
...
@@ -491,6 +494,7 @@ void margo_thread_sleep(
/* set data needed for sleep callback */
ABT_mutex_create
(
&
(
sleep_cb_dat
.
mutex
));
ABT_cond_create
(
&
(
sleep_cb_dat
.
cond
));
sleep_cb_dat
.
is_asleep
=
1
;
/* initialize the sleep timer */
margo_timer_init
(
mid
,
&
sleep_timer
,
margo_thread_sleep_cb
,
...
...
@@ -498,7 +502,8 @@ void margo_thread_sleep(
/* yield thread for specified timeout */
ABT_mutex_lock
(
sleep_cb_dat
.
mutex
);
ABT_cond_wait
(
sleep_cb_dat
.
cond
,
sleep_cb_dat
.
mutex
);
while
(
sleep_cb_dat
.
is_asleep
)
ABT_cond_wait
(
sleep_cb_dat
.
cond
,
sleep_cb_dat
.
mutex
);
ABT_mutex_unlock
(
sleep_cb_dat
.
mutex
);
return
;
...
...
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