Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Institute of Technical Acoustics (ITA)
VACore
Commits
49d71dde
Commit
49d71dde
authored
Feb 21, 2018
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing problem with real-time logger thread dtor
parent
786e7ef2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
28 deletions
+40
-28
src/VALog.cpp
src/VALog.cpp
+24
-18
src/VALog.h
src/VALog.h
+16
-10
No files found.
src/VALog.cpp
View file @
49d71dde
#include "VALog.h"
/*
* --------------------------------------------------------------------------------------------
*
...
...
@@ -12,9 +10,9 @@
*
* --------------------------------------------------------------------------------------------
*/
#include <algorithm>
#include "VALog.h"
#include <VistaInterProcComm/Concurrency/VistaPriority.h>
#include <algorithm>
std
::
ostream
*
VA_STDOUT
=
&
std
::
cout
;
...
...
@@ -25,7 +23,7 @@ void VALog_setOutputStream( std::ostream* os )
std
::
ostream
*
VA_STDERR
=
&
std
::
cerr
;
void
VALog_setErrorStream
(
std
::
ostream
*
os
)
{
{
VA_STDERR
=
os
;
}
...
...
@@ -68,9 +66,19 @@ CVARealtimeLogger::CVARealtimeLogger()
//int iPriority = VistaPriority::VISTA_MIN_PRIORITY;
//SetPriority(iPriority); // TODO stienen/wefers: klren wie man eine low priority setzen kann
// @todo: sort out how to properly use vista threads.
Run
();
}
CVARealtimeLogger
::~
CVARealtimeLogger
()
{
m_bStop
=
true
;
m_evTrigger
.
SignalEvent
();
m_evTrigger
.
WaitForEvent
(
true
);
StopGently
(
false
);
}
static
CVARealtimeLogger
g_oInstance
;
CVARealtimeLogger
*
CVARealtimeLogger
::
GetInstance
()
{
...
...
@@ -95,15 +103,6 @@ void CVARealtimeLogger::Unregister( CVARealtimeLogStream* pStream )
Trigger
();
}
CVARealtimeLogger
::~
CVARealtimeLogger
()
{
m_bStop
=
true
;
m_evTrigger
.
SignalEvent
();
// TODO: Problematisch mit Matlab
// StopGently(false);
StopGently
(
false
);
}
void
CVARealtimeLogger
::
Trigger
()
{
++
m_iTriggerCnt
;
...
...
@@ -112,15 +111,21 @@ void CVARealtimeLogger::Trigger()
bool
CVARealtimeLogger
::
LoopBody
()
{
if
(
(
m_iTriggerCnt
==
0
)
&&
!
m_bStop
)
{
if
(
(
m_iTriggerCnt
==
0
)
&&
!
m_bStop
)
{
// Blockierend warten
m_evTrigger
.
WaitForEvent
(
true
);
if
(
m_bStop
==
true
)
{
m_evTrigger
.
SignalEvent
();
return
false
;
}
// Daten greifen
std
::
vector
<
CVALogItem
>
vLogItems
;
m_mxRegistration
.
Lock
();
std
::
list
<
CVARealtimeLogStream
*>::
const_iterator
it
;
std
::
list
<
CVARealtimeLogStream
*
>::
const_iterator
it
;
for
(
it
=
m_lpStreams
.
begin
();
it
!=
m_lpStreams
.
end
();
++
it
)
{
CVARealtimeLogStream
*
pStream
=
*
it
;
...
...
@@ -141,7 +146,8 @@ bool CVARealtimeLogger::LoopBody()
}
// Stop-Flag berprfen, ggf. selbst beenden
if
(
m_bStop
)
{
if
(
m_bStop
)
{
IndicateLoopEnd
();
return
false
;
}
...
...
src/VALog.h
View file @
49d71dde
...
...
@@ -100,14 +100,14 @@ public:
//! Ausgabe
bool
LoopBody
();
void
PreLoop
()
{};
void
PostLoop
()
{};
inline
void
PreLoop
()
{};
inline
void
PostLoop
()
{};
private:
VistaThreadEvent
m_evTrigger
;
ITAAtomicInt
m_iTriggerCnt
;
ITAAtomicBool
m_bStop
;
std
::
list
<
CVARealtimeLogStream
*>
m_lpStreams
;
std
::
list
<
CVARealtimeLogStream
*
>
m_lpStreams
;
VistaMutex
m_mxRegistration
;
};
...
...
@@ -117,29 +117,35 @@ private:
* niederpriorisiertem Thread auf die Konsole oder Visual Studio Ausgabe
* auszugeben.
*/
class
CVARealtimeLogStream
{
class
CVARealtimeLogStream
{
public:
CVARealtimeLogStream
(
ITAClock
*
pClock
=
ITAClock
::
getDefaultClock
()
)
:
m_pClock
(
pClock
)
{
inline
CVARealtimeLogStream
(
ITAClock
*
pClock
=
ITAClock
::
getDefaultClock
()
)
:
m_pClock
(
pClock
)
{
// Bei Ausgabe-Thread registrieren (Singleton)
CVARealtimeLogger
::
GetInstance
()
->
Register
(
this
);
}
virtual
~
CVARealtimeLogStream
()
{
virtual
~
CVARealtimeLogStream
()
{
// Bei Thread deregistieren
CVARealtimeLogger
::
GetInstance
()
->
Unregister
(
this
);
}
std
::
string
GetName
()
const
{
std
::
string
GetName
()
const
{
return
m_sName
;
}
void
SetName
(
const
std
::
string
&
sName
)
{
void
SetName
(
const
std
::
string
&
sName
)
{
m_sName
=
sName
;
}
// Ausgabe
void
Printf
(
const
char
*
format
,
...
)
{
void
Printf
(
const
char
*
format
,
...
)
{
char
buf
[
16384
];
va_list
args
;
va_start
(
args
,
format
);
...
...
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