Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
wolf_projects
wolf_lib
wolf
Commits
0dc055ca
Commit
0dc055ca
authored
6 years ago
by
Angel Santamaria-Navarro
Browse files
Options
Downloads
Patches
Plain Diff
Improve SB addNotification
parent
d86d14a4
No related branches found
No related tags found
1 merge request
!211
State blocks
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/state_block.cpp
+30
-0
30 additions, 0 deletions
src/state_block.cpp
src/state_block.h
+1
-7
1 addition, 7 deletions
src/state_block.h
with
31 additions
and
7 deletions
src/state_block.cpp
+
30
−
0
View file @
0dc055ca
...
@@ -29,6 +29,36 @@ void StateBlock::setFixed(bool _fixed)
...
@@ -29,6 +29,36 @@ void StateBlock::setFixed(bool _fixed)
getProblem
()
->
notifyStateBlock
(
shared_from_this
(),
StateBlock
::
Notification
::
UPDATE_FIX
);
getProblem
()
->
notifyStateBlock
(
shared_from_this
(),
StateBlock
::
Notification
::
UPDATE_FIX
);
}
}
void
StateBlock
::
addNotification
(
const
StateBlock
::
Notification
_new_notification
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
notifictions_mut_
);
if
(
_new_notification
==
Notification
::
ADD
)
{
// When an ADD arrives, the state is already the newest,
// thus old instructions can be cleared
if
(
shared_from_this
()
->
notifications_
.
size
()
>
0
)
notifications_
.
clear
();
// Push ADD notification to the front
notifications_
.
emplace_front
(
Notification
::
ADD
);
}
else
if
(
_new_notification
==
Notification
::
REMOVE
)
{
// If we want to remove a block that still has an ADD instruction
// we can just clear all notifications and just keep the remove
if
(
!
notifications_
.
empty
()
&&
notifications_
.
front
()
==
Notification
::
ADD
)
notifications_
.
clear
();
else
{
notifications_
.
clear
();
notifications_
.
emplace_back
(
Notification
::
REMOVE
);
}
}
else
// UPDATE_FIX; UPDATE_STATE
notifications_
.
emplace_back
(
_new_notification
);
}
StateBlock
::
Notifications
StateBlock
::
consumeNotifications
()
const
StateBlock
::
Notifications
StateBlock
::
consumeNotifications
()
const
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
notifictions_mut_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
notifictions_mut_
);
...
...
This diff is collapsed.
Click to expand it.
src/state_block.h
+
1
−
7
View file @
0dc055ca
...
@@ -34,7 +34,7 @@ public:
...
@@ -34,7 +34,7 @@ public:
enum
class
Notification
:
std
::
size_t
enum
class
Notification
:
std
::
size_t
{
{
ADD
=
0
,
ADD
=
1
,
REMOVE
,
REMOVE
,
UPDATE_STATE
,
UPDATE_STATE
,
UPDATE_FIX
UPDATE_FIX
...
@@ -239,12 +239,6 @@ inline void StateBlock::setLocalParametrizationPtr(LocalParametrizationBasePtr _
...
@@ -239,12 +239,6 @@ inline void StateBlock::setLocalParametrizationPtr(LocalParametrizationBasePtr _
local_param_ptr_
=
_local_param
;
local_param_ptr_
=
_local_param
;
}
}
inline
void
StateBlock
::
addNotification
(
const
StateBlock
::
Notification
_new_notification
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
notifictions_mut_
);
notifications_
.
emplace_back
(
_new_notification
);
}
inline
void
StateBlock
::
setProblem
(
const
ProblemPtr
_problem
)
inline
void
StateBlock
::
setProblem
(
const
ProblemPtr
_problem
)
{
{
problem_ptr_
=
_problem
;
problem_ptr_
=
_problem
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment