Improving critical section lock, removed warnings.

parent 9f4297e3
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
* ---------------------------------------------------------------- * ----------------------------------------------------------------
* *
*/ */
// $Id: ITACriticalSection.h 2971 2012-11-22 12:10:45Z stienen $
#ifndef INCLUDE_WATCHER_ITA_CRITICALSECTION #ifndef INCLUDE_WATCHER_ITA_CRITICALSECTION
#define INCLUDE_WATCHER_ITA_CRITICALSECTION #define INCLUDE_WATCHER_ITA_CRITICALSECTION
...@@ -46,7 +45,7 @@ public: ...@@ -46,7 +45,7 @@ public:
ITACriticalSection(); ITACriticalSection();
//! Kopierkonstruktor //! Kopierkonstruktor
ITACriticalSection(const ITACriticalSection& cs); ITACriticalSection( const ITACriticalSection& cs );
//! Destruktor //! Destruktor
virtual ~ITACriticalSection(); virtual ~ITACriticalSection();
...@@ -62,7 +61,7 @@ public: ...@@ -62,7 +61,7 @@ public:
virtual void enter() const; virtual void enter() const;
virtual void leave() const; virtual void leave() const;
ITACriticalSection& operator=(const ITACriticalSection& rhs); ITACriticalSection& operator=( const ITACriticalSection& rhs );
private: private:
ITACriticalSectionImpl* m_pImpl; ITACriticalSectionImpl* m_pImpl;
...@@ -73,13 +72,22 @@ class ITA_BASE_API ITACriticalSectionLock ...@@ -73,13 +72,22 @@ class ITA_BASE_API ITACriticalSectionLock
{ {
public: public:
//! Konstruktor. Betritt den kritischen Bereich. //! Konstruktor. Betritt den kritischen Bereich.
ITACriticalSectionLock(const ITACriticalSection& cs) : m_cs(cs) { m_cs.enter(); } inline ITACriticalSectionLock( const ITACriticalSection& cs )
: m_cs( cs )
{
m_cs.enter();
};
//! Destruktor. Verlässt den kritischen Bereich. //! Destruktor. Verlässt den kritischen Bereich.
~ITACriticalSectionLock() { m_cs.leave(); } ~ITACriticalSectionLock()
{
m_cs.leave();
};
private: private:
const ITACriticalSection& m_cs; const ITACriticalSection& m_cs;
ITACriticalSectionLock& operator=( ITACriticalSectionLock& );
}; };
#endif // INCLUDE_WATCHER_ITA_CRITICALSECTION #endif // INCLUDE_WATCHER_ITA_CRITICALSECTION
......
// $Id: ITACriticalSection.cpp 2825 2012-07-27 14:26:20Z stienen $
#include "ITACriticalSection.h" #include "ITACriticalSection.h"
#ifdef WIN32 #ifdef WIN32
#include "ITACriticalSectionWin32Impl.h" #include "ITACriticalSectionWin32Impl.h"
ITACriticalSection::ITACriticalSection() { ITACriticalSection::ITACriticalSection()
{
m_pImpl = new ITACriticalSectionWin32Impl; m_pImpl = new ITACriticalSectionWin32Impl;
} }
...@@ -14,14 +13,16 @@ ITACriticalSection::ITACriticalSection() { ...@@ -14,14 +13,16 @@ ITACriticalSection::ITACriticalSection() {
#include "ITACriticalSectionPosixImpl.h" #include "ITACriticalSectionPosixImpl.h"
ITACriticalSection::ITACriticalSection() { ITACriticalSection::ITACriticalSection()
{
m_pImpl = new ITACriticalSectionPosixImpl; m_pImpl = new ITACriticalSectionPosixImpl;
} }
#endif // WIN32 / POSIX #endif // WIN32 / POSIX
ITACriticalSection::ITACriticalSection(const ITACriticalSection& cs) { ITACriticalSection::ITACriticalSection( const ITACriticalSection& )
{
/* /*
* [fwe 2009-12-15] Bugfix * [fwe 2009-12-15] Bugfix
* *
...@@ -36,24 +37,29 @@ ITACriticalSection::ITACriticalSection(const ITACriticalSection& cs) { ...@@ -36,24 +37,29 @@ ITACriticalSection::ITACriticalSection(const ITACriticalSection& cs) {
*/ */
} }
ITACriticalSection::~ITACriticalSection() { ITACriticalSection::~ITACriticalSection()
{
delete m_pImpl; delete m_pImpl;
} }
bool ITACriticalSection::tryenter() const { bool ITACriticalSection::tryenter() const
{
// Delegieren // Delegieren
return m_pImpl->tryenter(); return m_pImpl->tryenter();
} }
void ITACriticalSection::enter() const { void ITACriticalSection::enter() const
{
m_pImpl->enter(); m_pImpl->enter();
} }
void ITACriticalSection::leave() const { void ITACriticalSection::leave() const
{
m_pImpl->leave(); m_pImpl->leave();
} }
ITACriticalSection& ITACriticalSection::operator=(const ITACriticalSection& rhs) { ITACriticalSection& ITACriticalSection::operator=( const ITACriticalSection& )
{
/* /*
* Mann kann Critical sections nicht zuweisen, denn sie haben keinen wert. * Mann kann Critical sections nicht zuweisen, denn sie haben keinen wert.
* Wohl aber eine definierte Identität der erhalten bleiben muss. * Wohl aber eine definierte Identität der erhalten bleiben muss.
......
...@@ -26,10 +26,9 @@ ...@@ -26,10 +26,9 @@
using namespace std; using namespace std;
int main( int argc, char** argv ) int main( int, char** )
{ {
ITASampleBuffer sb; ITASampleBuffer sb;
return 0; return 0;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment