Commit 636bf228 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Improving critical section lock, removed warnings.

parent 9f4297e3
......@@ -15,7 +15,6 @@
* ----------------------------------------------------------------
*
*/
// $Id: ITACriticalSection.h 2971 2012-11-22 12:10:45Z stienen $
#ifndef INCLUDE_WATCHER_ITA_CRITICALSECTION
#define INCLUDE_WATCHER_ITA_CRITICALSECTION
......@@ -46,7 +45,7 @@ public:
ITACriticalSection();
//! Kopierkonstruktor
ITACriticalSection(const ITACriticalSection& cs);
ITACriticalSection( const ITACriticalSection& cs );
//! Destruktor
virtual ~ITACriticalSection();
......@@ -62,7 +61,7 @@ public:
virtual void enter() const;
virtual void leave() const;
ITACriticalSection& operator=(const ITACriticalSection& rhs);
ITACriticalSection& operator=( const ITACriticalSection& rhs );
private:
ITACriticalSectionImpl* m_pImpl;
......@@ -73,13 +72,22 @@ class ITA_BASE_API ITACriticalSectionLock
{
public:
//! 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.
~ITACriticalSectionLock() { m_cs.leave(); }
~ITACriticalSectionLock()
{
m_cs.leave();
};
private:
const ITACriticalSection& m_cs;
ITACriticalSectionLock& operator=( ITACriticalSectionLock& );
};
#endif // INCLUDE_WATCHER_ITA_CRITICALSECTION
......
// $Id: ITACriticalSection.cpp 2825 2012-07-27 14:26:20Z stienen $
#include "ITACriticalSection.h"
#ifdef WIN32
#include "ITACriticalSectionWin32Impl.h"
ITACriticalSection::ITACriticalSection() {
ITACriticalSection::ITACriticalSection()
{
m_pImpl = new ITACriticalSectionWin32Impl;
}
......@@ -14,14 +13,16 @@ ITACriticalSection::ITACriticalSection() {
#include "ITACriticalSectionPosixImpl.h"
ITACriticalSection::ITACriticalSection() {
ITACriticalSection::ITACriticalSection()
{
m_pImpl = new ITACriticalSectionPosixImpl;
}
#endif // WIN32 / POSIX
ITACriticalSection::ITACriticalSection(const ITACriticalSection& cs) {
ITACriticalSection::ITACriticalSection( const ITACriticalSection& )
{
/*
* [fwe 2009-12-15] Bugfix
*
......@@ -36,24 +37,29 @@ ITACriticalSection::ITACriticalSection(const ITACriticalSection& cs) {
*/
}
ITACriticalSection::~ITACriticalSection() {
ITACriticalSection::~ITACriticalSection()
{
delete m_pImpl;
}
bool ITACriticalSection::tryenter() const {
bool ITACriticalSection::tryenter() const
{
// Delegieren
return m_pImpl->tryenter();
}
void ITACriticalSection::enter() const {
void ITACriticalSection::enter() const
{
m_pImpl->enter();
}
void ITACriticalSection::leave() const {
void ITACriticalSection::leave() const
{
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.
* Wohl aber eine definierte Identität der erhalten bleiben muss.
......
......@@ -26,10 +26,9 @@
using namespace std;
int main( int argc, char** argv )
int main( int, char** )
{
ITASampleBuffer sb;
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