Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
thallium
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sds
thallium
Commits
9a422f4d
Commit
9a422f4d
authored
Feb 27, 2019
by
Matthieu Dorier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added the possibility for threads to sleep
parent
310b6251
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
include/thallium/thread.hpp
include/thallium/thread.hpp
+13
-0
src/thread.cpp
src/thread.cpp
+5
-0
No files found.
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