Commit 9a422f4d authored by Matthieu Dorier's avatar Matthieu Dorier

added the possibility for threads to sleep

parent 310b6251
......@@ -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);
};
}
......
......@@ -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);
}
}
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