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
11464c19
Commit
11464c19
authored
Oct 27, 2014
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debugging 4tw
parent
c47eea61
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
libcaf_core/caf/detail/single_reader_queue.hpp
libcaf_core/caf/detail/single_reader_queue.hpp
+0
-7
libcaf_core/src/condition_variable.cpp
libcaf_core/src/condition_variable.cpp
+17
-3
No files found.
libcaf_core/caf/detail/single_reader_queue.hpp
View file @
11464c19
...
...
@@ -89,13 +89,11 @@ class single_reader_queue {
if
(
!
e
)
{
// if tail is nullptr, the queue has been closed
m_delete
(
new_element
);
printf
(
"enqueue return enqueue_result::queue_closed
\n
"
);
return
enqueue_result
::
queue_closed
;
}
// a dummy is never part of a non-empty list
new_element
->
next
=
is_dummy
(
e
)
?
nullptr
:
e
;
if
(
m_stack
.
compare_exchange_strong
(
e
,
new_element
))
{
printf
(
"enqueue return enqueue_result::unblocked_reader or enqueue_result::success
\n
"
);
return
(
e
==
reader_blocked_dummy
())
?
enqueue_result
::
unblocked_reader
:
enqueue_result
::
success
;
}
...
...
@@ -224,20 +222,15 @@ class single_reader_queue {
bool
synchronized_enqueue
(
Mutex
&
mtx
,
CondVar
&
cv
,
pointer
new_element
)
{
switch
(
enqueue
(
new_element
))
{
case
enqueue_result
:
:
unblocked_reader
:
{
printf
(
"synchronized_enqueue -> unblocked_reader
\n
"
);
unique_lock
<
Mutex
>
guard
(
mtx
);
printf
(
"synchronized_enqueue -> unblocked_reader -> created guard
\n
"
);
cv
.
notify_one
();
printf
(
"synchronized_enqueue -> unblocked_reader -> notified one
\n
"
);
return
true
;
}
case
enqueue_result
:
:
success
:
{
printf
(
"synchronized_enqueue -> success
\n
"
);
// enqueued message to a running actor's mailbox
return
true
;
}
case
enqueue_result
:
:
queue_closed
:
{
printf
(
"synchronized_enqueue -> queue_closed
\n
"
);
// actor no longer alive
return
false
;
}
...
...
libcaf_core/src/condition_variable.cpp
View file @
11464c19
//#include <system_error>
#include <cstdio>
#include <stdexcept>
extern
"C"
{
...
...
@@ -22,13 +23,17 @@ condition_variable::~condition_variable() {
void
condition_variable
::
notify_one
()
noexcept
{
unsigned
old_state
=
disableIRQ
();
priority_queue_node_t
*
head
=
priority_queue_remove_head
(
&
m_queue
);
printf
(
"[notify_one] head is %x with data %u
\n
"
,
head
,
head
->
data
);
printf
(
"[notify_one] data %u
\n
"
,
head
->
data
);
int
other_prio
=
-
1
;
if
(
head
!=
NULL
)
{
tcb_t
*
other_thread
=
(
tcb_t
*
)
sched_threads
[
head
->
data
];
printf
(
"[notify_one] other thread is %x at %x
\n
"
,
other_thread
,
head
->
data
);
if
(
other_thread
)
{
other_prio
=
other_thread
->
priority
;
sched_set_status
(
other_thread
,
STATUS_PENDING
);
}
printf
(
"[notify_one] setting data to -1u
\n
"
);
head
->
data
=
-
1u
;
}
restoreIRQ
(
old_state
);
...
...
@@ -53,6 +58,7 @@ void condition_variable::notify_all() noexcept {
other_prio
=
max_prio
(
other_prio
,
other_thread
->
priority
);
sched_set_status
(
other_thread
,
STATUS_PENDING
);
}
printf
(
"[notify_all] setting data to -1u
\n
"
);
head
->
data
=
-
1u
;
}
restoreIRQ
(
old_state
);
...
...
@@ -70,9 +76,17 @@ void condition_variable::wait(unique_lock<mutex>& lock) noexcept {
n
.
data
=
sched_active_pid
;
n
.
next
=
NULL
;
printf
(
"[wait] adding node: %x with data %x
\n
"
,
&
n
,
n
.
data
);
/* the signaling thread may not hold the mutex, the queue is not thread safe */
unsigned
old_state
=
disableIRQ
();
priority_queue_add
(
&
m_queue
,
&
n
);
printf
(
"[wait] node added: %x with data %x
\n
"
,
&
n
,
n
.
data
);
priority_queue_node_t
*
head
=
priority_queue_remove_head
(
&
m_queue
);
printf
(
"[wait] head is: %x with data %x
\n
"
,
head
,
head
->
data
);
priority_queue_add
(
&
m_queue
,
&
n
);
restoreIRQ
(
old_state
);
mutex_unlock_and_sleep
(
lock
.
mutex
()
->
native_handle
());
if
(
n
.
data
!=
-
1u
)
{
...
...
@@ -85,7 +99,7 @@ void condition_variable::wait(unique_lock<mutex>& lock) noexcept {
mutex_lock
(
lock
.
mutex
()
->
native_handle
());
}
void
condition_variable
::
do_timed_wait
(
unique_lock
<
mutex
>&
lock
,
void
condition_variable
::
do_timed_wait
(
unique_lock
<
mutex
>&
lock
,
time_point
<
system_clock
,
nanoseconds
>
tp
)
noexcept
{
if
(
!
lock
.
owns_lock
())
{
...
...
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