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
59b0bb35
Commit
59b0bb35
authored
Dec 09, 2014
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix clock namespace issue and remove unused code
parent
774b8f16
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
24 deletions
+7
-24
libcaf_core/caf/chrono.hpp
libcaf_core/caf/chrono.hpp
+1
-1
libcaf_core/caf/condition_variable.hpp
libcaf_core/caf/condition_variable.hpp
+1
-14
libcaf_core/caf/thread.hpp
libcaf_core/caf/thread.hpp
+2
-2
libcaf_core/src/thread.cpp
libcaf_core/src/thread.cpp
+3
-7
No files found.
libcaf_core/caf/chrono.hpp
View file @
59b0bb35
...
...
@@ -104,7 +104,7 @@ inline bool operator>=(const time_point& lhs, const time_point& rhs) {
namespace
caf
{
using
time_point
=
std
::
chrono
::
high_resolution_clock
::
time_point
;
inline
std
::
chrono
::
time_point
<
std
::
chrono
::
high_resolution_clock
>
now
()
{
inline
time_point
<
std
::
chrono
::
high_resolution_clock
>
now
()
{
return
std
::
chrono
::
high_resolution_clock
::
now
();
}
...
...
libcaf_core/caf/condition_variable.hpp
View file @
59b0bb35
...
...
@@ -28,7 +28,6 @@
#include "vtimer.h"
#include "caf/mutex.hpp"
#include "caf/chrono.hpp"
...
...
@@ -73,17 +72,6 @@ class condition_variable {
priority_queue_t
m_queue
;
};
template
<
class
T
,
class
Rep
,
class
Period
>
inline
typename
std
::
enable_if
<
std
::
chrono
::
__is_duration
<
T
>::
value
,
T
>::
type
ceil
(
std
::
chrono
::
duration
<
Rep
,
Period
>
duration
)
{
using
namespace
std
::
chrono
;
T
res
=
duration_cast
<
T
>
(
duration
);
if
(
res
<
duration
)
{
++
res
;
}
return
res
;
}
template
<
class
Predicate
>
void
condition_variable
::
wait
(
unique_lock
<
mutex
>&
lock
,
Predicate
pred
)
{
while
(
!
pred
())
{
...
...
@@ -130,8 +118,7 @@ template <class Rep, class Period, class Predicate>
inline
bool
condition_variable
::
wait_for
(
unique_lock
<
mutex
>&
lock
,
const
std
::
chrono
::
duration
<
Rep
,
Period
>&
timeout_duration
,
Predicate
pred
)
{
return
wait_until
(
lock
,
std
::
chrono
::
steady_clock
::
now
()
+
timeout_duration
,
std
::
move
(
pred
));
return
wait_until
(
lock
,
now
()
+
timeout_duration
,
std
::
move
(
pred
));
}
}
// namespace caf
...
...
libcaf_core/caf/thread.hpp
View file @
59b0bb35
...
...
@@ -126,14 +126,14 @@ namespace this_thread {
mutex
mtx
;
condition_variable
cv
;
unique_lock
<
mutex
>
lk
(
mtx
);
while
(
Clock
::
now
()
<
sleep_time
)
{
while
(
now
()
<
sleep_time
)
{
cv
.
wait_until
(
lk
,
sleep_time
);
}
}
template
<
class
Period
>
inline
void
sleep_until
(
const
std
::
chrono
::
time_point
<
std
::
chrono
::
steady_clock
,
Period
>&
sleep_time
)
{
sleep_for
(
sleep_time
-
std
::
chrono
::
steady_clock
::
now
());
sleep_for
(
sleep_time
-
now
());
}
}
// namespace this_thread
...
...
libcaf_core/src/thread.cpp
View file @
59b0bb35
...
...
@@ -38,7 +38,7 @@ thread::~thread() {
void
thread
::
join
()
{
if
(
this
->
get_id
()
==
this_thread
::
get_id
())
{
throw
system_error
(
make_error_code
(
errc
::
resource_deadlock_would_occur
),
"Joining this leads to a deadlock."
);
"Joining this leads to a deadlock."
);
}
if
(
joinable
())
{
auto
status
=
thread_getstatus
(
m_handle
);
...
...
@@ -49,21 +49,17 @@ void thread::join() {
m_handle
=
thread_uninitialized
;
}
else
{
throw
system_error
(
make_error_code
(
errc
::
invalid_argument
),
"Can not join an unjoinable thread."
);
"Can not join an unjoinable thread."
);
}
// missing: no_such_process system error
}
void
thread
::
join
()
{
// you can't join threads
}
void
thread
::
detach
()
{
if
(
joinable
())
{
m_handle
=
thread_uninitialized
;
}
else
{
throw
system_error
(
make_error_code
(
errc
::
invalid_argument
),
"Can not detach an unjoinable thread."
);
"Can not detach an unjoinable thread."
);
}
}
...
...
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