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
7553ba1b
Commit
7553ba1b
authored
7 years ago
by
Jeremie Deray
Browse files
Options
Downloads
Patches
Plain Diff
add mutex to ProcessorBase and use it in ProcessorMotion::keyFrameCallback
parent
928494d5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/processor_base.h
+5
-0
5 additions, 0 deletions
src/processor_base.h
src/processor_motion.cpp
+14
-0
14 additions, 0 deletions
src/processor_motion.cpp
with
19 additions
and
0 deletions
src/processor_base.h
+
5
−
0
View file @
7553ba1b
...
...
@@ -40,6 +40,9 @@ class ProcessorBase : public NodeBase, public std::enable_shared_from_this<Proce
static
unsigned
int
processor_id_count_
;
public:
using
mutex_t
=
std
::
recursive_timed_mutex
;
ProcessorBase
(
const
std
::
string
&
_type
,
const
Scalar
&
_time_tolerance
=
0
);
virtual
~
ProcessorBase
();
void
remove
();
...
...
@@ -92,6 +95,8 @@ class ProcessorBase : public NodeBase, public std::enable_shared_from_this<Proce
protected
:
unsigned
int
processor_id_
;
Scalar
time_tolerance_
;
///< self time tolerance for adding a capture into a frame
mutex_t
mut_
;
};
}
...
...
This diff is collapsed.
Click to expand it.
src/processor_motion.cpp
+
14
−
0
View file @
7553ba1b
...
...
@@ -41,6 +41,8 @@ void ProcessorMotion::process(CaptureBasePtr _incoming_ptr)
return
;
}
std
::
lock_guard
<
mutex_t
>
lock
(
mut_
);
if
(
status_
==
IDLE
)
{
// std::cout << "PM: IDLE" << std::endl;
...
...
@@ -228,6 +230,18 @@ bool ProcessorMotion::keyFrameCallback(FrameBasePtr _new_keyframe, const Scalar&
assert
(
_new_keyframe
->
getTrajectoryPtr
()
!=
nullptr
&&
"ProcessorMotion::keyFrameCallback: key frame must be in the trajectory."
);
using
rep_t
=
std
::
chrono
::
milliseconds
::
rep
;
// Tying to self-lock the mutex for duration == _time_tol_other
if
(
!
timed_mut_
.
try_lock_for
(
std
::
chrono
::
milliseconds
(
rep_t
(
_time_tol_other
))))
{
WOLF_DEBUG
(
"ProcessorMotion::keyFrameCallback could not acquire the mutex on time."
);
return
false
;
}
// Lock object takes ownership of the mutex
std
::
lock_guard
<
mutex_t
>
lock
(
timed_mut_
,
std
::
adopt_lock
);
// get keyframe's time stamp
TimeStamp
new_ts
=
_new_keyframe
->
getTimeStamp
();
...
...
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