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
965cefbd
authored
8 years ago
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mtapi_cpp: fixed automatic initialization
parent
3926d7a1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
mtapi_cpp/src/node.cc
+8
-3
No files found.
mtapi_cpp/src/node.cc
View file @
965cefbd
...
@@ -32,7 +32,7 @@ namespace mtapi {
...
@@ -32,7 +32,7 @@ namespace mtapi {
embb
::
mtapi
::
Node
*
embb
::
mtapi
::
Node
::
node_instance_
=
NULL
;
embb
::
mtapi
::
Node
*
embb
::
mtapi
::
Node
::
node_instance_
=
NULL
;
#if MTAPI_CPP_AUTOMATIC_INITIALIZE
#if MTAPI_CPP_AUTOMATIC_INITIALIZE
static
embb_spinlock_t
init_mutex
=
{
{
0
}
}
;
static
EMBB_BASE_BASIC_TYPE_SIZE_4
init_mutex
=
0
;
#endif
#endif
void
Node
::
Initialize
(
void
Node
::
Initialize
(
...
@@ -68,13 +68,18 @@ void Node::Initialize(
...
@@ -68,13 +68,18 @@ void Node::Initialize(
Node
&
Node
::
GetInstance
()
{
Node
&
Node
::
GetInstance
()
{
#if MTAPI_CPP_AUTOMATIC_INITIALIZE
#if MTAPI_CPP_AUTOMATIC_INITIALIZE
if
(
!
IsInitialized
())
{
if
(
!
IsInitialized
())
{
embb_spin_lock
(
&
init_mutex
);
EMBB_BASE_BASIC_TYPE_SIZE_4
compare
=
0
;
while
(
0
==
embb_internal__atomic_compare_and_swap_4
(
&
init_mutex
,
&
compare
,
1
))
{
compare
=
0
;
embb_thread_yield
();
}
if
(
!
IsInitialized
())
{
if
(
!
IsInitialized
())
{
Node
::
Initialize
(
Node
::
Initialize
(
MTAPI_CPP_AUTOMATIC_DOMAIN_ID
,
MTAPI_CPP_AUTOMATIC_NODE_ID
);
MTAPI_CPP_AUTOMATIC_DOMAIN_ID
,
MTAPI_CPP_AUTOMATIC_NODE_ID
);
atexit
(
Node
::
Finalize
);
atexit
(
Node
::
Finalize
);
}
}
embb_
spin_unlock
(
&
init_mutex
);
embb_
internal__atomic_store_4
(
&
init_mutex
,
0
);
}
}
return
*
node_instance_
;
return
*
node_instance_
;
#else
#else
...
...
This diff is collapsed.
Click to expand it.
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