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
be24fb3c
Commit
be24fb3c
authored
Sep 06, 2014
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add RIOT defs to single_read_queue
Clashes with logging
parent
9ee799d4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
15 deletions
+52
-15
libcaf_core/caf/detail/single_reader_queue.hpp
libcaf_core/caf/detail/single_reader_queue.hpp
+52
-15
No files found.
libcaf_core/caf/detail/single_reader_queue.hpp
View file @
be24fb3c
...
@@ -22,13 +22,13 @@
...
@@ -22,13 +22,13 @@
#include <list>
#include <list>
#include <deque>
#include <deque>
#include <mutex>
#include <atomic>
#include <atomic>
#include <memory>
#include <memory>
#include <limits>
#include <limits>
#include <condition_variable> // std::cv_status
#include "caf/mutex.hpp"
#include "caf/config.hpp"
#include "caf/config.hpp"
#include "caf/condition_variable.hpp"
#include "caf/detail/intrusive_partitioned_list.hpp"
#include "caf/detail/intrusive_partitioned_list.hpp"
...
@@ -218,6 +218,56 @@ class single_reader_queue {
...
@@ -218,6 +218,56 @@ class single_reader_queue {
* support for synchronized access *
* support for synchronized access *
**************************************************************************/
**************************************************************************/
#ifdef __RIOTBUILD_FLAG
bool
synchronized_enqueue
(
pthread_mutex_t
&
mtx
,
pthread_cond_t
&
cv
,
pointer
new_element
)
{
//template <class Mutex, class CondVar>
//bool synchronized_enqueue(Mutex& mtx, CondVar& cv, pointer new_element) {
switch
(
enqueue
(
new_element
))
{
case
enqueue_result
:
:
unblocked_reader
:
{
pthread_mutex_lock
(
&
mtx
);
pthread_cond_signal
(
&
cv
);
pthread_mutex_unlock
(
&
mtx
);
return
true
;
}
}
}
void
synchronized_await
(
pthread_mutex_t
&
mtx
,
pthread_cond_t
&
cv
)
{
//template <class Mutex, class CondVar>
//void synchronized_await(Mutex& mtx, CondVar& cv) {
CAF_REQUIRE
(
!
closed
());
if
(
!
can_fetch_more
()
&&
try_block
())
{
// todo what does the try_block?
pthread_mutex_lock
(
&
mtx
);
while
(
blocked
())
{
pthread_cond_wait
(
&
cv
,
&
mtx
);
}
pthread_mutex_unlock
(
&
mtx
);
}
}
bool
synchronized_await
(
pthread_mutex_t
&
mtx
,
pthread_cond_t
&
cv
,
const
struct
timespec
&
timeout
)
{
//template <class Mutex, class CondVar, class TimePoint>
//bool synchronized_await(Mutex& mtx, CondVar& cv, const TimePoint& timeout) {
CAF_REQUIRE
(
!
closed
());
if
(
!
can_fetch_more
()
&&
try_block
())
{
pthread_mutex_lock
(
&
mtx
);
while
(
blocked
())
{
auto
rc
=
pthread_cond_timedwait
(
&
cv
,
&
mtx
,
&
timeout
);
if
(
rc
==
ETIMEDOUT
)
{
//if (cv.wait_until(guard, timeout) == std::cv_status::timeout) {
// if we're unable to set the queue from blocked to empty,
// than there's a new element in the list
pthread_mutex_unlock
(
&
mtx
);
return
!
try_unblock
();
}
}
}
pthread_mutex_unlock
(
&
mtx
);
return
true
;
}
#else
template
<
class
Mutex
,
class
CondVar
>
template
<
class
Mutex
,
class
CondVar
>
bool
synchronized_enqueue
(
Mutex
&
mtx
,
CondVar
&
cv
,
pointer
new_element
)
{
bool
synchronized_enqueue
(
Mutex
&
mtx
,
CondVar
&
cv
,
pointer
new_element
)
{
switch
(
enqueue
(
new_element
))
{
switch
(
enqueue
(
new_element
))
{
...
@@ -236,20 +286,7 @@ class single_reader_queue {
...
@@ -236,20 +286,7 @@ class single_reader_queue {
// should be unreachable
// should be unreachable
CAF_CRITICAL
(
"invalid result of enqueue()"
);
CAF_CRITICAL
(
"invalid result of enqueue()"
);
}
}
#ifdef __RIOTBUILD_FLAG
template
<
class
Mutex
,
class
CondVar
>
void
synchronized_await
(
Mutex
&
mtx
,
CondVar
&
cv
)
{
CAF_REQUIRE
(
!
closed
());
}
template
<
class
Mutex
,
class
CondVar
,
class
TimePoint
>
bool
synchronized_await
(
Mutex
&
mtx
,
CondVar
&
cv
,
const
TimePoint
&
timeout
)
{
CAF_REQUIRE
(
!
closed
());
}
#else
template
<
class
Mutex
,
class
CondVar
>
template
<
class
Mutex
,
class
CondVar
>
void
synchronized_await
(
Mutex
&
mtx
,
CondVar
&
cv
)
{
void
synchronized_await
(
Mutex
&
mtx
,
CondVar
&
cv
)
{
CAF_ASSERT
(
!
closed
());
CAF_ASSERT
(
!
closed
());
...
...
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