diff --git a/contrib/Netgen/libsrc/general/parthreads.cpp b/contrib/Netgen/libsrc/general/parthreads.cpp index 81e9d0b6cce14da76c8e1cb196666a9fab2c3fc1..9cbf42c8abcb1ce4e994e508adf5a889b204b14b 100644 --- a/contrib/Netgen/libsrc/general/parthreads.cpp +++ b/contrib/Netgen/libsrc/general/parthreads.cpp @@ -1,40 +1,40 @@ -/**************************************************************************/ -/* File: parthreads.cpp */ -/* Author: Joachim Schoeberl */ -/* Date: 01. Jun. 95 */ -/**************************************************************************/ - - -#include <mystdlib.h> -#include <myadt.hpp> - -/* - -namespace netgen -{ - using namespace netgen; - -#ifdef WIN32 - - NgLock :: NgLock (NgMutex & mut) - : sl(&mut.cs) - { - ; - } - - void NgLock :: Lock () - { - sl.Lock(); - } - void NgLock :: UnLock () - { - sl.Unlock(); - } - - -#else - -#endif -} - -*/ +/**************************************************************************/ +/* File: parthreads.cpp */ +/* Author: Joachim Schoeberl */ +/* Date: 01. Jun. 95 */ +/**************************************************************************/ + + +#include <mystdlib.h> +#include <myadt.hpp> + +/* + +namespace netgen +{ + using namespace netgen; + +#ifdef WIN32 + + NgLock :: NgLock (NgMutex & mut) + : sl(&mut.cs) + { + ; + } + + void NgLock :: Lock () + { + sl.Lock(); + } + void NgLock :: UnLock () + { + sl.Unlock(); + } + + +#else + +#endif +} + +*/ diff --git a/contrib/Netgen/libsrc/general/parthreads.hpp b/contrib/Netgen/libsrc/general/parthreads.hpp index 99dd0176331c268977fa1582e9b0da47c21629b0..98a2246d472c40cc1fcf258d7cb861aba695af48 100644 --- a/contrib/Netgen/libsrc/general/parthreads.hpp +++ b/contrib/Netgen/libsrc/general/parthreads.hpp @@ -1,126 +1,126 @@ -#ifndef FILE_PARTHREADS -#define FILE_PARTHREADS - -/**************************************************************************/ -/* File: parthreads.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 22. Nov. 2000 */ -/**************************************************************************/ - -/* - Parallel thread, Mutex, -*/ - -#ifdef NO_PARALLEL_THREADS - -class NgMutex { }; - -class NgLock -{ -public: - NgLock (NgMutex & mut, bool lock = 0) { ; } - void Lock () { ; } - void UnLock () { ; } -}; - - -#else - -#ifdef WIN32 - -class NgMutex -{ - CCriticalSection cs; - -public: - NgMutex () - { ; } - friend class NgLock; -}; - -class NgLock -{ - CSingleLock sl; - bool locked; -public: - NgLock (NgMutex & mut, bool lock = 0) - : sl(&mut.cs) - { - if (lock) sl.Lock(); - locked = lock; - } - - ~NgLock () - { - if (locked) sl.Unlock(); - } - - void Lock () - { - sl.Lock(); - locked = 1; - } - - void UnLock () - { - sl.Unlock(); - locked = 0; - } -}; - -#else - - -#include <pthread.h> - -class NgMutex -{ - pthread_mutex_t mut; -public: - NgMutex () - { - pthread_mutex_init (&mut, NULL); - } - friend class NgLock; -}; - -class NgLock -{ - pthread_mutex_t & mut; - bool locked; -public: - NgLock (NgMutex & ngmut, bool lock = 0) - : mut (ngmut.mut) - { - if (lock) pthread_mutex_lock (&mut); - locked = lock; - }; - - ~NgLock() - { - if (locked) pthread_mutex_unlock (&mut); - } - - void Lock () - { - pthread_mutex_lock (&mut); - locked = 1; - } - void UnLock () - { - pthread_mutex_unlock (&mut); - locked = 0; - } - /* - int TryLock () - { - return pthread_mutex_trylock (&mut); - } - */ -}; - -#endif - -#endif - -#endif +#ifndef FILE_PARTHREADS +#define FILE_PARTHREADS + +/**************************************************************************/ +/* File: parthreads.hh */ +/* Author: Joachim Schoeberl */ +/* Date: 22. Nov. 2000 */ +/**************************************************************************/ + +/* + Parallel thread, Mutex, +*/ + +#ifdef NO_PARALLEL_THREADS + +class NgMutex { }; + +class NgLock +{ +public: + NgLock (NgMutex & mut, bool lock = 0) { ; } + void Lock () { ; } + void UnLock () { ; } +}; + + +#else + +#ifdef WIN32 + +class NgMutex +{ + CCriticalSection cs; + +public: + NgMutex () + { ; } + friend class NgLock; +}; + +class NgLock +{ + CSingleLock sl; + bool locked; +public: + NgLock (NgMutex & mut, bool lock = 0) + : sl(&mut.cs) + { + if (lock) sl.Lock(); + locked = lock; + } + + ~NgLock () + { + if (locked) sl.Unlock(); + } + + void Lock () + { + sl.Lock(); + locked = 1; + } + + void UnLock () + { + sl.Unlock(); + locked = 0; + } +}; + +#else + + +#include <pthread.h> + +class NgMutex +{ + pthread_mutex_t mut; +public: + NgMutex () + { + pthread_mutex_init (&mut, NULL); + } + friend class NgLock; +}; + +class NgLock +{ + pthread_mutex_t & mut; + bool locked; +public: + NgLock (NgMutex & ngmut, bool lock = 0) + : mut (ngmut.mut) + { + if (lock) pthread_mutex_lock (&mut); + locked = lock; + }; + + ~NgLock() + { + if (locked) pthread_mutex_unlock (&mut); + } + + void Lock () + { + pthread_mutex_lock (&mut); + locked = 1; + } + void UnLock () + { + pthread_mutex_unlock (&mut); + locked = 0; + } + /* + int TryLock () + { + return pthread_mutex_trylock (&mut); + } + */ +}; + +#endif + +#endif + +#endif