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
thallium
Commits
9a422f4d
Commit
9a422f4d
authored
Feb 27, 2019
by
Matthieu Dorier
Browse files
added the possibility for threads to sleep
parent
310b6251
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/thallium/thread.hpp
View file @
9a422f4d
...
...
@@ -41,6 +41,7 @@ class thread_exception : public exception {
class
pool
;
class
xstream
;
class
scheduler
;
class
engine
;
enum
class
thread_state
:
std
::
int32_t
{
ready
=
ABT_THREAD_STATE_READY
,
...
...
@@ -218,6 +219,7 @@ class thread {
TL_THREAD_ASSERT
(
ABT_thread_create
(
p
,
f
,
arg
,
attr
.
native_handle
(),
&
t
));
return
managed
<
thread
>
(
t
);
}
void
destroy
()
{
if
(
m_thread
!=
ABT_THREAD_NULL
)
ABT_thread_free
(
&
m_thread
);
...
...
@@ -517,6 +519,17 @@ class thread {
static
void
yield_to
(
const
thread
&
other
)
{
TL_THREAD_ASSERT
(
ABT_thread_yield_to
(
other
.
m_thread
));
}
/**
* @brief Makes the current thread sleep for at least the given
* amount of time. The provided engine must be in an active progress
* loop, since it this progress loops that periodically checks for
* timer expiration.
*
* @param eng engine that will check for timer expiration.
* @param ms time to sleep in milliseconds.
*/
static
void
sleep
(
engine
&
eng
,
double
ms
);
};
}
...
...
src/thread.cpp
View file @
9a422f4d
...
...
@@ -2,6 +2,7 @@
#include <thallium/pool.hpp>
#include <thallium/xstream.hpp>
#include <thallium/scheduler.hpp>
#include <thallium/engine.hpp>
namespace
thallium
{
...
...
@@ -23,4 +24,8 @@ pool thread::get_last_pool() const {
return
pool
(
p
);
}
void
thread
::
sleep
(
engine
&
eng
,
double
ms
)
{
margo_thread_sleep
(
eng
.
get_margo_instance
(),
ms
);
}
}
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