Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
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
cpp-libs
Actor Framework
Commits
0ed394ab
Commit
0ed394ab
authored
Nov 12, 2014
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug in join and sleep_for
parent
5ac04156
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
libcaf_core/src/thread.cpp
libcaf_core/src/thread.cpp
+12
-6
No files found.
libcaf_core/src/thread.cpp
View file @
0ed394ab
#include <time.h>
extern
"C"
{
#include "vtimer.h"
}
#include <cerrno>
#include <cerrno>
#include <system_error>
#include <system_error>
...
@@ -22,12 +24,12 @@ void thread::join() {
...
@@ -22,12 +24,12 @@ void thread::join() {
"Joining this leads to a deadlock."
);
"Joining this leads to a deadlock."
);
}
}
if
(
joinable
())
{
if
(
joinable
())
{
m_handle
=
thread_uninitialized
;
auto
status
=
thread_getstatus
(
m_handle
);
auto
status
=
thread_getstatus
(
m_handle
);
if
(
status
!=
STATUS_NOT_FOUND
&&
status
!=
STATUS_STOPPED
)
{
if
(
status
!=
STATUS_NOT_FOUND
&&
status
!=
STATUS_STOPPED
)
{
m_data
->
joining_thread
=
sched_active_pid
;
m_data
->
joining_thread
=
sched_active_pid
;
thread_sleep
();
thread_sleep
();
}
}
m_handle
=
thread_uninitialized
;
}
else
{
}
else
{
throw
system_error
(
make_error_code
(
errc
::
invalid_argument
),
throw
system_error
(
make_error_code
(
errc
::
invalid_argument
),
"Can not join an unjoinable thread."
);
"Can not join an unjoinable thread."
);
...
@@ -60,7 +62,6 @@ void sleep_for(const chrono::nanoseconds& ns) {
...
@@ -60,7 +62,6 @@ void sleep_for(const chrono::nanoseconds& ns) {
seconds
s
=
duration_cast
<
seconds
>
(
ns
);
seconds
s
=
duration_cast
<
seconds
>
(
ns
);
timespec
ts
;
timespec
ts
;
using
ts_sec
=
decltype
(
ts
.
tv_sec
);
using
ts_sec
=
decltype
(
ts
.
tv_sec
);
// typedef decltype(ts.tv_sec) ts_sec;
constexpr
ts_sec
ts_sec_max
=
numeric_limits
<
ts_sec
>::
max
();
constexpr
ts_sec
ts_sec_max
=
numeric_limits
<
ts_sec
>::
max
();
if
(
s
.
count
()
<
ts_sec_max
)
{
if
(
s
.
count
()
<
ts_sec_max
)
{
ts
.
tv_sec
=
static_cast
<
ts_sec
>
(
s
.
count
());
ts
.
tv_sec
=
static_cast
<
ts_sec
>
(
s
.
count
());
...
@@ -69,7 +70,12 @@ void sleep_for(const chrono::nanoseconds& ns) {
...
@@ -69,7 +70,12 @@ void sleep_for(const chrono::nanoseconds& ns) {
ts
.
tv_sec
=
ts_sec_max
;
ts
.
tv_sec
=
ts_sec_max
;
ts
.
tv_nsec
=
giga
::
num
-
1
;
ts
.
tv_nsec
=
giga
::
num
-
1
;
}
}
while
(
nanosleep
(
&
ts
,
&
ts
)
==
-
1
&&
errno
==
EINTR
)
{
;
}
timex_t
reltime
;
reltime
.
seconds
=
ts
.
tv_sec
;
reltime
.
microseconds
=
ts
.
tv_nsec
/
1000u
;
vtimer_t
timer
;
vtimer_set_wakeup
(
&
timer
,
reltime
,
sched_active_pid
);
thread_sleep
();
}
}
}
}
...
...
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