Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7aa7fb0f
authored
Feb 04, 2016
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tasks_cpp: creation of groups and queues is now thread-safe as documented
parent
2f7e8112
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
tasks_cpp/include/embb/tasks/node.h
+3
-0
tasks_cpp/src/node.cc
+9
-0
No files found.
tasks_cpp/include/embb/tasks/node.h
View file @
7aa7fb0f
...
...
@@ -29,6 +29,7 @@
#include <list>
#include <embb/base/core_set.h>
#include <embb/base/mutex.h>
#include <embb/mtapi/c/mtapi.h>
#include <embb/tasks/action.h>
#include <embb/tasks/task.h>
...
...
@@ -223,6 +224,8 @@ class Node {
mtapi_action_hndl_t
action_handle_
;
std
::
list
<
Queue
*>
queues_
;
std
::
list
<
Group
*>
groups_
;
embb
::
base
::
Spinlock
queue_lock_
;
embb
::
base
::
Spinlock
group_lock_
;
};
}
// namespace tasks
...
...
tasks_cpp/src/node.cc
View file @
7aa7fb0f
...
...
@@ -31,6 +31,7 @@
#include <embb/base/memory_allocation.h>
#include <embb/base/exceptions.h>
#include <embb/base/thread.h>
#include <embb/tasks/tasks.h>
#if TASKS_CPP_AUTOMATIC_INITIALIZE
#include <embb/base/mutex.h>
...
...
@@ -234,7 +235,11 @@ void Node::Finalize() {
Group
&
Node
::
CreateGroup
()
{
Group
*
group
=
embb
::
base
::
Allocation
::
New
<
Group
>
();
while
(
!
group_lock_
.
TryLock
(
1024
))
{
embb
::
base
::
Thread
::
CurrentYield
();
}
groups_
.
push_back
(
group
);
group_lock_
.
Unlock
();
return
*
group
;
}
...
...
@@ -249,7 +254,11 @@ void Node::DestroyGroup(Group & group) {
Queue
&
Node
::
CreateQueue
(
mtapi_uint_t
priority
,
bool
ordered
)
{
Queue
*
queue
=
embb
::
base
::
Allocation
::
New
<
Queue
>
(
priority
,
ordered
);
while
(
!
queue_lock_
.
TryLock
(
1024
))
{
embb
::
base
::
Thread
::
CurrentYield
();
}
queues_
.
push_back
(
queue
);
queue_lock_
.
Unlock
();
return
*
queue
;
}
...
...
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