summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraustriancoder <austriancoder>2004-10-09 16:50:10 +0000
committeraustriancoder <austriancoder>2004-10-09 16:50:10 +0000
commit1d16151e84e9fc7f53c9ee5d7c5e56034d741df0 (patch)
treed8e1997290b8e5bf9a42ffd62cec69a1f11265ab
parent03b99effaa75c4b9bf81e5e1a0841e0b1d522e5a (diff)
downloadvdr-plugin-dxr3-1d16151e84e9fc7f53c9ee5d7c5e56034d741df0.tar.gz
vdr-plugin-dxr3-1d16151e84e9fc7f53c9ee5d7c5e56034d741df0.tar.bz2
logger now thread safe
-rw-r--r--HISTORY5
-rw-r--r--dxr3log.c3
-rw-r--r--dxr3log.h16
3 files changed, 21 insertions, 3 deletions
diff --git a/HISTORY b/HISTORY
index a34866b..8197c4a 100644
--- a/HISTORY
+++ b/HISTORY
@@ -230,7 +230,7 @@ NOTE: I havent found time to include all of the languages, will be done in pre2
- fixed dxr3osd_subpicutre.c - thanks to Paavo Hartikainen <pahartik@sci.fi>
-2004-0?-??: Version 0.2.3-pre3
+2004-??-??: Version 0.2.3-pre3
- fixed output of anamorphic video, if tv aspect is configured to 16:9 in DVB setup menu
thanks Seppo Ingalsuo <seppo.ingalsuo@iki.fi>
@@ -254,4 +254,5 @@ NOTE: I havent found time to include all of the languages, will be done in pre2
because the pre2 seems to put this dxr3plugin.log random in some folders - reporded by Martin Dauskardt <md001@gmx.de>
- extended cDxr3MemcpyBench::Rdtsc(uint32_t config_flags)
support for non x86 arch
- support for cpu's, which dont support rdtsc timing \ No newline at end of file
+ support for cpu's, which dont support rdtsc timing
+- logger now thread safe \ No newline at end of file
diff --git a/dxr3log.c b/dxr3log.c
index 680dd6b..0095c57 100644
--- a/dxr3log.c
+++ b/dxr3log.c
@@ -22,6 +22,9 @@
#include "dxr3log.h"
// ==================================
+cMutex* cLog::m_pMutex = new cMutex;
+
+// ==================================
//! constructor
cLog::cLog()
{
diff --git a/dxr3log.h b/dxr3log.h
index bfabfe6..fdb6bbd 100644
--- a/dxr3log.h
+++ b/dxr3log.h
@@ -25,6 +25,7 @@
#include <fstream>
#include <string>
#include "dxr3singleton.h"
+#include "dxr3vdrincludes.h"
// ==================================
//! A log class.
@@ -32,6 +33,7 @@
With this nice util dxr3plugin generates and mange a log file. In this
file the developer/enduser can find informations and can find errors,
problems and ohter stuff.
+ The logging class is now thread-safe!
*/
class cLog : public Singleton<cLog>
{
@@ -41,31 +43,36 @@ public:
~cLog() { Close(); }
- void SetForceFlush(const bool v) { m_ForeFlush = v; }
+ void SetForceFlush(const bool v) { Lock(); m_ForeFlush = v; Unlock(); }
bool GetForceFlush() const { return m_ForeFlush; }
// write type data to log file.
template <class Type>
inline cLog& operator << ( Type item )
{
+ Lock();
if (m_LogOpen)
{
m_LogStream << item;
if (m_ForeFlush) m_LogStream.flush();
}
+ Unlock();
return *this;
}
inline cLog& operator << ( size_t item )
{
+ Lock();
if (m_LogOpen)
{
m_LogStream << (unsigned int)item;
if (m_ForeFlush) m_LogStream.flush();
}
+ Unlock();
return *this;
}
inline cLog& operator << ( bool item )
{
+ Lock();
if (m_LogOpen)
{
if (item == true)
@@ -78,6 +85,7 @@ public:
}
if (m_ForeFlush) m_LogStream.flush();
}
+ Unlock();
return *this;
}
@@ -88,6 +96,12 @@ private:
void Open(std::string Filename); // with this function we open our logfile
void Close(); // with this function we close our logfile
+
+protected:
+ static cMutex* m_pMutex; ///< mutex
+
+ static void Lock() { cLog::m_pMutex->Lock(); }
+ static void Unlock() { cLog::m_pMutex->Unlock(); }
};