You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(622) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(303) |
Feb
(64) |
Mar
(5) |
Apr
(63) |
May
(82) |
Jun
(53) |
Jul
(50) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Christian P. <cp...@us...> - 2005-04-25 10:51:24
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14574/include/pclasses/Util Modified Files: ManagedThread.h WorkQueue.h Log Message: - Changed return type of Thread::main() to long Index: WorkQueue.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Util/WorkQueue.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- WorkQueue.h 28 Jan 2005 11:39:36 -0000 1.3 +++ WorkQueue.h 25 Apr 2005 10:51:14 -0000 1.4 @@ -22,12 +22,13 @@ #define _P_WorkQueue_h_ #include <pclasses/Queue.h> -#include <pclasses/List.h> #include <pclasses/System/Mutex.h> #include <pclasses/System/Condition.h> #include <pclasses/System/Semaphore.h> #include <pclasses/Util/ManagedThread.h> +#include <list> + namespace P { namespace Util { @@ -45,17 +46,17 @@ State state() const throw(); - int retVal() const throw(); + long retVal() const throw(); void process(); protected: - virtual int run() = 0; + virtual long run() = 0; virtual void finish() = 0; private: State _state; - int _retVal; + long _retVal; }; class WorkQueue { @@ -80,7 +81,7 @@ ~WorkerThread() throw(); private: - virtual int mainLoop(); + virtual long mainLoop(); WorkQueue& _queue; }; @@ -96,7 +97,7 @@ private: WorkQueue& _queue; unsigned int _numThreads; - list<WorkerThread*> _threads; + std::list<WorkerThread*> _threads; }; } // !namespace Utils Index: ManagedThread.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Util/ManagedThread.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ManagedThread.h 28 Jan 2005 11:39:36 -0000 1.3 +++ ManagedThread.h 25 Apr 2005 10:51:14 -0000 1.4 @@ -75,7 +75,7 @@ resources. You should signal the thread to stop before waiting for it's termination. */ - int join() throw(System::SystemError); + long join() throw(System::SystemError); //! Wait for state-change State wait(int stateMask); @@ -107,7 +107,7 @@ \return zero if the initialization was the successfull, non-zero exit-code otherwise. */ - virtual int init(); + virtual long init(); //! Threads main-loop /*! @@ -116,7 +116,7 @@ The implementation of this method should frequently call shouldRun() to allow suspend, resume and exit notifies. */ - virtual int mainLoop() = 0; + virtual long mainLoop() = 0; //! Cleanup method /*! @@ -143,7 +143,7 @@ private: //! Implements the Threads main-method - virtual int main(); + virtual long main(); //! Changes state and notifies the Condition void changeState(State newState); |
From: Christian P. <cp...@us...> - 2005-04-25 10:51:22
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14574/include/pclasses/System Modified Files: Thread.h Log Message: - Changed return type of Thread::main() to long Index: Thread.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/Thread.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Thread.h 28 Jan 2005 17:36:13 -0000 1.5 +++ Thread.h 25 Apr 2005 10:51:14 -0000 1.6 @@ -47,7 +47,7 @@ Wait until the thread has exited. \return the threads exit-code (returned by main()) */ - virtual int join() throw(LogicError, SystemError); + virtual long join() throw(LogicError, SystemError); //! Test if thread is detached bool detached() const throw(); @@ -61,7 +61,7 @@ Semaphore* sem = 0) throw(SystemError); protected: - virtual int main() = 0; + virtual long main() = 0; private: struct Handle; |
From: Christian P. <cp...@us...> - 2005-04-24 11:50:52
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14444 Modified Files: Callback.h Makefile.am Log Message: - Added missing export macros - Fixed CallbackN generation in Makefile.am Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Makefile.am,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Makefile.am 7 Feb 2005 18:46:30 -0000 1.12 +++ Makefile.am 24 Apr 2005 11:50:41 -0000 1.13 @@ -5,6 +5,7 @@ METASOURCES = AUTO all_callbacks: + if [ ! -e "$(top_builddir)/include/pclasses/CallbackN1.h" ]; then bash $(top_srcdir)/include/pclasses/CallbackN.sh; fi if [ "$(top_builddir)/include/pclasses/CallbackN.sh" -nt "$(top_builddir)/include/pclasses/CallbackN1.h" ]; then bash $(top_srcdir)/include/pclasses/CallbackN.sh; fi all_callbacks_clean: Index: Callback.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Callback.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Callback.h 2 Feb 2005 15:54:42 -0000 1.7 +++ Callback.h 24 Apr 2005 11:50:40 -0000 1.8 @@ -21,11 +21,12 @@ #ifndef P_Callback_h #define P_Callback_h +#include <pclasses/Export.h> #include <pclasses/Exception.h> namespace P { -class CallbackArgs { +class PCORE_EXPORT CallbackArgs { public: CallbackArgs(int numArgs) throw(); virtual ~CallbackArgs() throw(); @@ -39,7 +40,7 @@ }; //! Callback base class -class Callback { +class PCORE_EXPORT Callback { public: struct RetType { }; @@ -53,7 +54,7 @@ /* ----------------- Callback0 ------------------ */ //! Callback arguments with no arguments -class CallbackArgs0: public CallbackArgs { +class PCORE_EXPORT CallbackArgs0: public CallbackArgs { public: CallbackArgs0() throw(); CallbackArgs* clone() const; |
From: Christian P. <cp...@us...> - 2005-04-24 11:40:35
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9552 Modified Files: Semaphore.h ProcessIO.h Pipe.h Mutex.h File.h Condition.h CriticalSection.h Log Message: - Added missing export macros Index: Pipe.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/Pipe.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Pipe.h 30 Jan 2005 17:10:07 -0000 1.9 +++ Pipe.h 24 Apr 2005 11:40:20 -0000 1.10 @@ -21,6 +21,7 @@ #ifndef P_System_Pipe_h #define P_System_Pipe_h +#include <pclasses/Export.h> #include <pclasses/IO/IODevice.h> #include <memory> @@ -29,7 +30,7 @@ namespace System { //! Anonymous pipe device -class Pipe: public IO::IODevice { +class PSYSTEM_EXPORT Pipe: public IO::IODevice { public: typedef std::pair<Pipe,Pipe> Pair; Index: Condition.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/Condition.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- Condition.h 22 Dec 2004 17:54:41 -0000 1.1.1.1 +++ Condition.h 24 Apr 2005 11:40:20 -0000 1.2 @@ -21,6 +21,7 @@ #ifndef P_System_Condition_h #define P_System_Condition_h +#include <pclasses/Export.h> #include <pclasses/NonCopyable.h> #include <pclasses/System/SystemError.h> #include <pclasses/System/Mutex.h> @@ -30,7 +31,7 @@ namespace System { //! Condition variable -class Condition: public NonCopyable { +class PSYSTEM_EXPORT Condition: public NonCopyable { public: Condition(Mutex& mtx) throw(SystemError); ~Condition() throw(); Index: CriticalSection.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/CriticalSection.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CriticalSection.h 23 Jan 2005 13:28:00 -0000 1.2 +++ CriticalSection.h 24 Apr 2005 11:40:20 -0000 1.3 @@ -21,6 +21,7 @@ #ifndef P_System_CriticalSection_h #define P_System_CriticalSection_h +#include <pclasses/Export.h> #include <pclasses/NonCopyable.h> #include <pclasses/Alloc.h> #include <pclasses/LockTraits.h> @@ -37,7 +38,7 @@ single process, and they should be slightly faster. \author Christian Prochnow <cp...@se...> */ -class CriticalSection: public NonCopyable { +class PSYSTEM_EXPORT CriticalSection: public NonCopyable { public: //! Constructor CriticalSection() throw(OutOfMemory); @@ -81,7 +82,7 @@ } \endcode */ - class ScopedLock { + class PSYSTEM_EXPORT ScopedLock { public: ScopedLock(CriticalSection& cs) throw(); ScopedLock(const ScopedLock& lck) throw(); Index: File.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/File.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- File.h 30 Jan 2005 17:09:46 -0000 1.11 +++ File.h 24 Apr 2005 11:40:20 -0000 1.12 @@ -21,6 +21,7 @@ #ifndef P_System_File_h #define P_System_File_h +#include <pclasses/Export.h> #include <pclasses/Unicode/String.h> #include <pclasses/IO/IODevice.h> @@ -35,7 +36,7 @@ /** File is a cross-platform abstraction for filesystem-based files. */ -class File: public IO::IODevice { +class PSYSTEM_EXPORT File: public IO::IODevice { public: File() throw(); Index: ProcessIO.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/ProcessIO.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ProcessIO.h 3 Jan 2005 13:50:44 -0000 1.2 +++ ProcessIO.h 24 Apr 2005 11:40:20 -0000 1.3 @@ -21,6 +21,7 @@ #ifndef P_System_ProcessIO_h #define P_System_ProcessIO_h +#include <pclasses/Export.h> #include <pclasses/IO/IODevice.h> #include <pclasses/System/Pipe.h> @@ -32,7 +33,7 @@ /*! \author Christian Prochnow <cp...@se...> */ -class ProcessIO: public IO::IODevice { +class PSYSTEM_EXPORT ProcessIO: public IO::IODevice { public: ProcessIO(const Pipe& in, const Pipe& out, const Pipe& err) throw(IO::IOError); ~ProcessIO() throw(); Index: Mutex.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/Mutex.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Mutex.h 23 Jan 2005 13:28:00 -0000 1.2 +++ Mutex.h 24 Apr 2005 11:40:20 -0000 1.3 @@ -21,6 +21,7 @@ #ifndef P_System_Mutex_h #define P_System_Mutex_h +#include <pclasses/Export.h> #include <pclasses/Alloc.h> #include <pclasses/NonCopyable.h> #include <pclasses/LockTraits.h> @@ -42,7 +43,7 @@ \ingroup core \author Christian Prochnow <cp...@se...> */ -class Mutex: public NonCopyable { +class PSYSTEM_EXPORT Mutex: public NonCopyable { public: //! Default constructor /*! @@ -126,7 +127,7 @@ } \endcode */ - class ScopedLock { + class PSYSTEM_EXPORT ScopedLock { public: ScopedLock(Mutex& mutex) throw(SystemError); ScopedLock(const ScopedLock& lck) throw(SystemError); Index: Semaphore.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/Semaphore.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- Semaphore.h 22 Dec 2004 17:54:42 -0000 1.1.1.1 +++ Semaphore.h 24 Apr 2005 11:40:20 -0000 1.2 @@ -21,6 +21,7 @@ #ifndef P_System_Semaphore_h #define P_System_Semaphore_h +#include <pclasses/Export.h> #include <pclasses/NonCopyable.h> #include <pclasses/System/SystemError.h> @@ -35,7 +36,7 @@ and wait until the counter is non-null and decrement it atomically. \author Christian Prochnow <cp...@se...> */ -class Semaphore: public NonCopyable { +class PSYSTEM_EXPORT Semaphore: public NonCopyable { public: //! Open-/creation- mode enum OpenMode { |
From: Christian P. <cp...@us...> - 2005-04-24 11:38:34
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8624 Modified Files: HTTPClient.h Log Message: - Added missing export macros Index: HTTPClient.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Net/HTTPClient.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- HTTPClient.h 17 Jan 2005 00:18:44 -0000 1.3 +++ HTTPClient.h 24 Apr 2005 11:38:21 -0000 1.4 @@ -21,6 +21,7 @@ #ifndef P_Net_HTTPClient_h #define P_Net_HTTPClient_h +#include <pclasses/Export.h> #include <pclasses/IO/URL.h> #include <pclasses/Net/Socket.h> #include <pclasses/Net/HTTPHeader.h> @@ -30,7 +31,7 @@ namespace Net { //! HTTP Request -class HTTPRequest { +class PNET_EXPORT HTTPRequest { public: //! HTTP Request methods enum Method { @@ -114,7 +115,7 @@ chunked-transfer-encoding from the client when reading a response body. */ -class HTTPResponse: public IO::IODevice { +class PNET_EXPORT HTTPResponse: public IO::IODevice { public: HTTPResponse(HTTPClient& client, const std::string& protoVer, int code, const std::string& reason); @@ -146,7 +147,7 @@ }; //! Hypertext-Transfer-Protocol client class -class HTTPClient: public StreamSocket { +class PNET_EXPORT HTTPClient: public StreamSocket { public: HTTPClient(); HTTPClient(Domain d); |
From: Christian P. <cp...@us...> - 2005-04-24 11:37:32
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7786 Modified Files: BZip2IOFilter.h Log Message: - Added missing export macro Index: BZip2IOFilter.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/BZip2IOFilter.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- BZip2IOFilter.h 7 Jan 2005 13:42:55 -0000 1.1 +++ BZip2IOFilter.h 24 Apr 2005 11:37:21 -0000 1.2 @@ -21,6 +21,7 @@ #ifndef P_IO_BZip2IOFilter_h #define P_IO_BZip2IOFilter_h +#include <pclasses/Export.h> #include <pclasses/IO/IOFilter.h> #include <pclasses/IO/BZip2.h> @@ -32,7 +33,7 @@ /*! bzlib2 stream based I/O Filter */ -class BZip2IOFilter: public IOFilter { +class PIO_EXPORT BZip2IOFilter: public IOFilter { public: BZip2IOFilter(); ~BZip2IOFilter(); |
From: Christian P. <cp...@us...> - 2005-04-24 11:36:40
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6961 Modified Files: AppDetails.h LogChannel.h LogManager.h LogMessage.h LogTarget.h Log Message: - Added missing export macros Index: LogMessage.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/LogMessage.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- LogMessage.h 10 Jan 2005 02:38:57 -0000 1.1 +++ LogMessage.h 24 Apr 2005 11:36:31 -0000 1.2 @@ -21,6 +21,7 @@ #ifndef P_LogMessage_h #define P_LogMessage_h +#include <pclasses/Export.h> #include <pclasses/DateTime.h> #include <pclasses/Unicode/String.h> #include <string> @@ -30,7 +31,7 @@ namespace App { //! Log message class -class LogMessage { +class PAPP_EXPORT LogMessage { public: //! Log message level enum Level { Index: AppDetails.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/AppDetails.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- AppDetails.h 31 Dec 2004 16:18:31 -0000 1.2 +++ AppDetails.h 24 Apr 2005 11:36:31 -0000 1.3 @@ -3,7 +3,10 @@ #include <string> #include <list> + +#include <pclasses/Export.h> #include <pclasses/Unicode/String.h> + namespace P { namespace App { using ::P::Unicode::String; @@ -26,7 +29,7 @@ not. */ - class AppDetails // throw() // i wish that would work + class PAPP_EXPORT AppDetails // throw() // i wish that would work { public: typedef std::list<String> DetailList; Index: LogTarget.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/LogTarget.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- LogTarget.h 10 Jan 2005 02:38:57 -0000 1.1 +++ LogTarget.h 24 Apr 2005 11:36:31 -0000 1.2 @@ -21,6 +21,7 @@ #ifndef P_LogTarget_h #define P_LogTarget_h +#include <pclasses/Export.h> #include <pclasses/Factory.h> #include <pclasses/IO/IOError.h> #include <pclasses/IO/URL.h> @@ -31,7 +32,7 @@ namespace App { //! Log message target -class LogTarget { +class PAPP_EXPORT LogTarget { public: LogTarget(); virtual ~LogTarget() throw(); Index: LogChannel.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/LogChannel.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- LogChannel.h 10 Jan 2005 02:38:57 -0000 1.1 +++ LogChannel.h 24 Apr 2005 11:36:31 -0000 1.2 @@ -21,6 +21,7 @@ #ifndef P_LogChannel_h #define P_LogChannel_h +#include <pclasses/Export.h> #include <pclasses/IO/IOError.h> #include <pclasses/App/LogMessage.h> @@ -35,7 +36,7 @@ class LogTarget; //! Log message channel -class LogChannel: public std::ostream { +class PAPP_EXPORT LogChannel: public std::ostream { public: typedef std::map<std::string, LogTarget*> TargetMap; Index: LogManager.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/LogManager.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- LogManager.h 10 Jan 2005 02:38:57 -0000 1.1 +++ LogManager.h 24 Apr 2005 11:36:31 -0000 1.2 @@ -21,6 +21,7 @@ #ifndef P_LogManager_h #define P_LogManager_h +#include <pclasses/Export.h> #include <pclasses/App/LogTarget.h> #include <pclasses/App/LogChannel.h> @@ -32,7 +33,7 @@ namespace App { //! Log manager -class LogManager { +class PAPP_EXPORT LogManager { public: //! Map of LogChannels typedef std::map<std::string,LogChannel*> ChannelMap; |
From: Christian P. <cp...@us...> - 2005-04-23 18:01:16
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/src/System Added Files: Timer.posix.cpp Log Message: Since we now have the cool signal-handling code, it makes this Timer possible! --- NEW FILE: Timer.posix.cpp --- /*************************************************************************** * Copyright (C) 2005 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "pclasses/System/Timer.h" #include "pclasses/System/EventQueue.h" #include "../System/SignalListener.h" #include <signal.h> #include <time.h> #include <errno.h> namespace P { namespace System { class Timer::Handle: public EventListener { public: Handle(EventQueue& evq, Timer* t) : EventListener(evq, t), timer(t), armed(false) { setup(); } Handle(Timer* t) : EventListener(t), timer(t), armed(false) { setup(); } ~Handle() { timer_delete(timerId); } void signaled(const Event& ev) { Timer* tmr = (Timer*)ev.sender(); tmr->sigExpired.fire(); tmr->expired(); } void setup() { sigevent se; se.sigev_notify = SIGEV_SIGNAL; se.sigev_signo = SIGALRM; se.sigev_value.sival_ptr = timer; if(timer_create(CLOCK_REALTIME, &se, &timerId) != 0) throw SystemError(errno, "Could not create timer", P_SOURCEINFO); } Timer* timer; bool armed; bool singleShot; timer_t timerId; }; class TimerSignalHandler: public System::SignalListener { public: TimerSignalHandler() : SignalListener(SIGALRM) { } void onSignal(const sigval& sv) { Timer::Handle* timer = 0; CriticalSection::ScopedLock lck(_timersCs); std::list<Timer::Handle*>::iterator i = _timers.begin(); while(i != _timers.end()) { timer = *i; if(timer->timer == sv.sival_ptr) { if(timer->singleShot) timer->armed = false; // we post this Event since signals are always handled by the // main-thread, and the EventListener may use a EventQueue // that runs in another thread... timer->eventQueue().post(Event(timer->sender(), 0)); } ++i; } } void add(Timer::Handle* timer) { CriticalSection::ScopedLock lck(_timersCs); _timers.push_back(timer); } void remove(Timer::Handle* timer) { CriticalSection::ScopedLock lck(_timersCs); std::list<Timer::Handle*>::iterator i = _timers.begin(); while(i != _timers.end()) { if(*i == timer) { _timers.erase(i); break; } ++i; } } static TimerSignalHandler& instance() { if(!_instance) { static CriticalSection cs; CriticalSection::ScopedLock lck(cs); _instance = new TimerSignalHandler(); } return *_instance; } private: CriticalSection _timersCs; std::list<Timer::Handle*> _timers; static TimerSignalHandler* _instance; }; TimerSignalHandler* TimerSignalHandler::_instance = 0; Timer::Timer() : _handle(new Handle(this)) { } Timer::Timer(EventQueue& evq) : _handle(new Handle(evq, this)) { } Timer::~Timer() { stop(); delete _handle; } void Timer::start(unsigned int timeout, bool singleShot) { unsigned int sec = timeout / 1000; unsigned int nsec = (timeout % 1000) * 1000000; struct itimerspec newVal, oldVal; newVal.it_value.tv_sec = sec; newVal.it_value.tv_nsec = nsec; newVal.it_interval.tv_sec = singleShot ? 0 : sec; newVal.it_interval.tv_nsec = singleShot ? 0 : nsec; if(timer_settime(_handle->timerId, 0, &newVal, &oldVal) != 0) throw SystemError(errno, "Could not set timer", P_SOURCEINFO); _handle->singleShot = singleShot; if(!_handle->armed) { TimerSignalHandler& timerSigHandler = TimerSignalHandler::instance(); timerSigHandler.add(_handle); _handle->armed = true; } } void Timer::stop() { if(_handle->armed) { struct itimerspec newVal, oldVal; newVal.it_value.tv_sec = 0; newVal.it_value.tv_nsec = 0; newVal.it_interval.tv_sec = 0; newVal.it_interval.tv_nsec = 0; if(timer_settime(_handle->timerId, 0, &newVal, &oldVal) != 0) throw SystemError(errno, "Could not set timer", P_SOURCEINFO); TimerSignalHandler& timerSigHandler = TimerSignalHandler::instance(); timerSigHandler.remove(_handle); _handle->armed = false; } } bool Timer::active() const throw() { return _handle->armed; } void Timer::expired() { } } // !namespace System } // !namespace P |
From: Christian P. <cp...@us...> - 2005-04-23 18:01:16
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/include/pclasses/System Added Files: Timer.h Log Message: Since we now have the cool signal-handling code, it makes this Timer possible! --- NEW FILE: Timer.h --- /*************************************************************************** * Copyright (C) 2005 by Christian Prochnow, SecuLogix GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef P_System_Timer_h #define P_System_Timer_h #include <pclasses/Export.h> #include <pclasses/Signal.h> namespace P { namespace System { class EventQueue; class PSYSTEM_EXPORT Timer { public: Timer(); Timer(EventQueue& evq); virtual ~Timer(); void start(unsigned int timeout, bool singleShot = true); void stop(); bool active() const throw(); Signal0<void> sigExpired; class Handle; protected: virtual void expired(); private: Handle* _handle; }; } // !namespace System } // !namespace P #endif |
From: Christian P. <cp...@us...> - 2005-04-23 17:57:34
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8142/src/System Modified Files: Process.posix.cpp Log Message: - Updated ProcessListener for new signal-handling code Index: Process.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Process.posix.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Process.posix.cpp 22 Feb 2005 13:21:49 -0000 1.2 +++ Process.posix.cpp 23 Apr 2005 17:57:26 -0000 1.3 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004 by Christian Prochnow * + * Copyright (C) 2004,2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -22,6 +22,9 @@ #include "pclasses/System/Directory.h" #include "pclasses/System/FileInfo.h" #include "pclasses/System/File.h" +#include "pclasses/System/CriticalSection.h" + +#include "../System/SignalListener.h" #include <sys/types.h> #include <sys/wait.h> @@ -33,9 +36,6 @@ #include <string> #include <list> -#include "../System/FdListener.h" -#include "../System/SignalListener.h" - namespace P { namespace System { @@ -45,11 +45,12 @@ ChildSignalHandler() : SignalListener(SIGCHLD) { } - void onSignal() + void onSignal(const sigval& sv) { ProcessListener* proc = 0; int exitCode = 0; + CriticalSection::ScopedLock lck(_procsCs); std::list<ProcessListener*>::iterator i = _procs.begin(); while(i != _procs.end()) { @@ -68,11 +69,13 @@ void add(ProcessListener* proc) { + CriticalSection::ScopedLock lck(_procsCs); _procs.push_back(proc); } void remove(ProcessListener* proc) { + CriticalSection::ScopedLock lck(_procsCs); std::list<ProcessListener*>::iterator i = _procs.begin(); while(i != _procs.end()) { @@ -99,6 +102,7 @@ } private: + CriticalSection _procsCs; std::list<ProcessListener*> _procs; static ChildSignalHandler* _instance; }; @@ -342,6 +346,11 @@ void ProcessListener::signaled(const Event& ev) { sigExited.fire(*this, ev.id()); + exited(ev.id()); +} + +void ProcessListener::exited(int exitCode) +{ } } // !namespace System |
From: Christian P. <cp...@us...> - 2005-04-23 17:57:34
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8142/include/pclasses/System Modified Files: Process.h Log Message: - Updated ProcessListener for new signal-handling code Index: Process.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/Process.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Process.h 22 Feb 2005 13:21:49 -0000 1.2 +++ Process.h 23 Apr 2005 17:57:13 -0000 1.3 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004 by Christian Prochnow * + * Copyright (C) 2004,2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -130,6 +130,9 @@ Signal2<void, ProcessListener&, int> sigExited; + protected: + virtual void exited(int exitCode); + private: void signaled(const Event& ev); Process& _proc; |
From: Christian P. <cp...@us...> - 2005-04-23 17:51:02
|
Update of /cvsroot/pclasses/pclasses2/src/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5601/src/App Modified Files: SimpleApp.cpp BackgroundApp.cpp Log Message: - Use new signal handling code Index: BackgroundApp.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/App/BackgroundApp.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- BackgroundApp.cpp 24 Jan 2005 22:58:39 -0000 1.2 +++ BackgroundApp.cpp 23 Apr 2005 17:50:53 -0000 1.3 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005 by Christian Prochnow * + * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -20,19 +20,32 @@ #include "pclasses/App/BackgroundApp.h" #include <iostream> -#include <signal.h> - #ifndef WIN32 # include <sys/types.h> # include <sys/stat.h> # include <fcntl.h> +# include "../System/SignalListener.h" #endif namespace P { namespace App { +#ifndef WIN32 +class ReloadSignalHandler: public System::SignalListener { + public: + ReloadSignalHandler() + : SignalListener(SIGHUP) { } + + void onSignal(const sigval& sv) + { + BackgroundApp& app = static_cast<BackgroundApp&>(theApp()); + app.reload(); + } +}; +#endif + BackgroundApp::BackgroundApp(const AppDetails& details) throw() : SimpleApp(details), _cmdLineParser() { @@ -166,9 +179,9 @@ int ret = SimpleApp::init(argc, argv); if(ret) return ret; - #ifdef SIGHUP - ::signal(SIGHUP, SimpleApp::signalHandler); - #endif +#ifndef WIN32 + new ReloadSignalHandler(); +#endif try { @@ -224,16 +237,6 @@ { } -void BackgroundApp::signal(int sig) -{ - SimpleApp::signal(sig); - - #ifdef SIGHUP - if(sig == SIGHUP) - reload(); - #endif -} - void BackgroundApp::reload() { } Index: SimpleApp.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/App/SimpleApp.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- SimpleApp.cpp 27 Feb 2005 17:19:10 -0000 1.5 +++ SimpleApp.cpp 23 Apr 2005 17:50:53 -0000 1.6 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004 by Christian Prochnow * + * Copyright (C) 2004,2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -20,10 +20,11 @@ #include "pclasses/System/EventQueue.h" #include "pclasses/App/SimpleApp.h" -#include <signal.h> +#include <iostream> #ifndef WIN32 # include "../System/FdListener.h" +# include "../System/SignalListener.h" #endif namespace P { @@ -66,26 +67,31 @@ return ret; } +#ifndef WIN32 +class TermSignalHandler: public System::SignalListener { + public: + TermSignalHandler(int sig) + : SignalListener(sig) { } + + void onSignal(const sigval& sv) + { + theApp().stop(1); + } +}; +#endif + int SimpleApp::init(int argc, char* argv[]) { - #ifdef WIN32 - { - //SetConsoleCtrlHandler((PHANDLER_ROUTINE)SIGTERM_handler, TRUE); - } - #endif - -// System::EventQueue& evq = System::EventQueue::instance(); -// System::FdListenerList& lst = System::FdListenerList::instance(evq); + // these calls create the main-thread instance of EventQueue and + // the file-descriptor listeners list + System::EventQueue& evq = System::EventQueue::instance(); + System::FdListenerList::instance(evq); - #ifdef SIGTERM - ::signal(SIGTERM, &signalHandler); - #endif - #ifdef SIGQUIT - ::signal(SIGQUIT, &signalHandler); - #endif - #ifdef SIGINT - ::signal(SIGINT, &signalHandler); - #endif +#ifndef WIN32 + new TermSignalHandler(SIGQUIT); + new TermSignalHandler(SIGINT); + new TermSignalHandler(SIGTERM); +#endif return 0; } @@ -121,44 +127,9 @@ { } -PCLASSES_RETSIGTYPE SimpleApp::signalHandler(int sig) -{ - #ifdef WIN32 - { - _theApp->signal(sig); - } - #else - { - ::signal(sig, SIG_IGN); - _theApp->signal(sig); - ::signal(sig, &signalHandler); - } - #endif -} - -void SimpleApp::signal(int sig) -{ - switch(sig) - { - #ifdef SIGTERM - case SIGTERM: - #endif - #ifdef SIGQUIT - case SIGQUIT: - #endif - #ifdef SIGINT - case SIGINT: - stop(1); - break; - #endif - default: - break; - } -} - -SimpleApp* theApp() throw() +SimpleApp& theApp() throw() { - return SimpleApp::_theApp; + return *SimpleApp::_theApp; } } // !namespace App |
From: Christian P. <cp...@us...> - 2005-04-23 17:51:02
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5601/include/pclasses/App Modified Files: SimpleApp.h BackgroundApp.h Log Message: - Use new signal handling code Index: BackgroundApp.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/BackgroundApp.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- BackgroundApp.h 24 Jan 2005 22:58:38 -0000 1.2 +++ BackgroundApp.h 23 Apr 2005 17:50:53 -0000 1.3 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005 by Christian Prochnow * + * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -36,17 +36,19 @@ BackgroundApp(const AppDetails& details) throw(); ~BackgroundApp() throw(); + //! Reload config & logfiles + virtual void reload(); + protected: void setCommandLineOpts(CmdLineOption* opts[]); void showCommandLineHelp(); + //! Send application to the background void daemonize(); - virtual void reload(); virtual int init(int argc, char* argv[]); virtual void cleanup(); virtual void finish(); - virtual void signal(int sig); private: CmdLineParser _cmdLineParser; Index: SimpleApp.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/SimpleApp.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SimpleApp.h 18 Jan 2005 17:52:24 -0000 1.2 +++ SimpleApp.h 23 Apr 2005 17:50:53 -0000 1.3 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004 by Christian Prochnow * + * Copyright (C) 2004,2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -21,7 +21,6 @@ #ifndef P_App_SimpleApp_h #define P_App_SimpleApp_h -#include <pclasses/pclasses-config.h> // reqd for PCLASSES_RETSIGTYPE #include <pclasses/Export.h> #include <pclasses/NonCopyable.h> #include <pclasses/System/Semaphore.h> @@ -64,7 +63,7 @@ const AppDetails& details() const throw(); //! Returns a pointer to the application object - friend SimpleApp* theApp() throw(); + friend SimpleApp& theApp() throw(); protected: //! Application init @@ -97,17 +96,12 @@ //! Called right before exiting the process, but after cleanup(). virtual void finish(); - //! Signal handler - virtual void signal(int sig); - //! Returns a reference to the exit-semaphore System::Semaphore& exitSem() const throw(); //! Returns the application's exit code int exitCode() const throw(); - static PCLASSES_RETSIGTYPE signalHandler(int); - private: System::Semaphore _exitSem; int _exitCode; |
From: Christian P. <cp...@us...> - 2005-04-23 17:48:11
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4241/src/System Modified Files: SignalListener.h SignalListener.posix.cpp Log Message: - Major updated to POSIX signal handling code Index: SignalListener.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/SignalListener.posix.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SignalListener.posix.cpp 26 Feb 2005 16:48:13 -0000 1.3 +++ SignalListener.posix.cpp 23 Apr 2005 17:48:03 -0000 1.4 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005 by Christian Prochnow * + * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -19,37 +19,47 @@ ***************************************************************************/ #include "pclasses/System/EventQueue.h" +#include "pclasses/CircularQueue.h" #include "SignalListener.h" #include "FdListener.h" + #include <signal.h> #include <unistd.h> #include <fcntl.h> - +#include <errno.h> + namespace P { namespace System { +// previously installed signal handlers will be saved ... +struct sigaction savedSigActions[64]; + + class SignalFdListener: public FdListener { public: SignalFdListener(int handle) - : FdListener(handle, FdListener::Read) + : FdListener(handle, FdListener::Read), _signals(64) { for(unsigned int i = 0; i < sizeof(_listeners) / sizeof(SignalListener*); i++) { _listeners[i] = 0; + savedSigActions[i].sa_flags = 0; + savedSigActions[i].sa_sigaction = 0; + savedSigActions[i].sa_handler = 0; } - System::FdListenerList& lst = - System::FdListenerList::instance(EventQueue::instance()); + FdListenerList& lst = + FdListenerList::instance(EventQueue::instance()); lst.addListener(this); } ~SignalFdListener() { - System::FdListenerList& lst = - System::FdListenerList::instance(EventQueue::instance()); + FdListenerList& lst = + FdListenerList::instance(EventQueue::instance()); lst.removeListener(this); } @@ -58,9 +68,9 @@ { if(!_instance) { - //int ret = /* unused var */ - ::pipe(_signalPipe); - // ^^^ todo??? check for error + int ret = ::pipe(_signalPipe); + if(ret != 0) + throw SystemError(errno, "Could not create pipe", P_SOURCEINFO); // make pipe nonblocking ... ::fcntl(_signalPipe[0], F_SETFL, O_NONBLOCK); @@ -72,11 +82,17 @@ return *_instance; } + /* + Adds a SignalListener to the list of handled signals + */ void addListener(int sig, SignalListener& l) { _listeners[sig] = &l; } + /* + Removes a SignalListener from the list of handled signals + */ void removeListener(SignalListener& l) { for(unsigned int i = 0; @@ -87,75 +103,107 @@ } } - void writeSignal(int sig) + /* + Queues the signal that was delivered and wakes up the + SignalFdListener ... + Note: This method is called directly from the signal handler !! + */ + void writeSignal(int sig, const sigval& sv) { - // read current pending signals ... - sigset_t sigSet; - int ret = ::read(_signalPipe[0], &sigSet, sizeof(sigset_t)); - if(ret != sizeof(sigset_t)) - sigemptyset(&sigSet); - - // add pending signal to set and write back to pipe - sigaddset(&sigSet, sig); - ::write(_signalPipe[1], &sigSet, sizeof(sigset_t)); + QueuedSig qs; + qs.sig = sig; + qs.val = sv; + _signals.push(qs); + ::write(_signalPipe[1], "W", 1); } protected: + + /* + Will be called by the FdListenerList after an event has occured + on our signal pipe. This should occur right after a signal has been + queued by a call to writeSignal(). + */ void onRead() { + // block all signals ... sigset_t blockedSet, oldSet; sigfillset(&blockedSet); sigprocmask(SIG_SETMASK, &blockedSet, &oldSet); - sigset_t sigSet; - int ret = ::read(fd(), &sigSet, sizeof(sigset_t)); - if(ret == sizeof(sigset_t)) + // deliver queued signals ... + QueuedSig qs; + while(!_signals.empty()) { - for(int i = 0; i < 64; i++) - { - if(sigismember(&sigSet, i) == 1 && _listeners[i]) - _listeners[i]->onSignal(); - } + qs = _signals.front(); + _signals.pop(); + + if(_listeners[qs.sig]) + _listeners[qs.sig]->onSignal(qs.val); } + // clear the signal pipe ... we don't want to get signaled forever + char tmp[64]; + int ret = ::read(fd(), tmp, 64); + + // restore blocked signal state ... sigprocmask(SIG_SETMASK, &oldSet, 0); } private: - SignalListener* _listeners[64]; - static int _signalPipe[2]; + struct QueuedSig { + int sig; + sigval val; + }; + + SignalListener* _listeners[64]; + CircularQueue<QueuedSig> _signals; + static int _signalPipe[2]; static SignalFdListener* _instance; }; int SignalFdListener::_signalPipe[2]; SignalFdListener* SignalFdListener::_instance = 0; -void signal_handler(int sig) +void signal_handler(int sig, siginfo_t* sigInfo, void* context) { SignalFdListener& l = SignalFdListener::instance(); - l.writeSignal(sig); + l.writeSignal(sig, sigInfo->si_value); + + // call previous signal handler ... + if(savedSigActions[sig].sa_flags & SA_SIGINFO + && savedSigActions[sig].sa_sigaction) + savedSigActions[sig].sa_sigaction(sig, sigInfo, context); + else if(savedSigActions[sig].sa_handler) + savedSigActions[sig].sa_handler(sig); } SignalListener::SignalListener(int sig) { - struct sigaction sa; - sa.sa_handler = &signal_handler; - sigfillset(&sa.sa_mask); // block all signals during signal handler's execution - sa.sa_flags = SA_RESTART; // restart system calls - - SignalFdListener& l = SignalFdListener::instance(); - l.addListener(sig, *this); - - sigaction(sig, &sa, 0); + setup(sig); } SignalListener::~SignalListener() { SignalFdListener& l = SignalFdListener::instance(); l.removeListener(*this); + + //TODO: restore previous signal handler ... } +void SignalListener::setup(int sig) +{ + struct sigaction sa; + sa.sa_sigaction = &signal_handler; + sigfillset(&sa.sa_mask); // block all signals during signal handler's execution + sa.sa_flags = SA_RESTART|SA_SIGINFO; // restart system calls, use 3 param sighandler + + SignalFdListener& l = SignalFdListener::instance(); + l.addListener(sig, *this); + sigaction(sig, &sa, &savedSigActions[sig]); } -} +} //! namespace System + +} //! namespace P Index: SignalListener.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/SignalListener.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SignalListener.h 17 Feb 2005 14:15:18 -0000 1.1 +++ SignalListener.h 23 Apr 2005 17:48:03 -0000 1.2 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005 by Christian Prochnow * + * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -20,19 +20,24 @@ #ifndef P_System_SignalListener #define P_System_SignalListener - + #include "pclasses/Export.h" +#include <signal.h> namespace P { namespace System { +//! Internal signal-listener for POSIX-systems class PSYSTEM_EXPORT SignalListener { public: SignalListener(int sig); virtual ~SignalListener(); - virtual void onSignal() = 0; + virtual void onSignal(const sigval& sv) = 0; + + private: + void setup(int sig); }; } // !namespace System |
From: Christian P. <cp...@us...> - 2005-04-23 17:47:17
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3585/src/System Modified Files: FdListener.h FdListener.posix.cpp Log Message: - Minor fix Index: FdListener.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/FdListener.posix.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FdListener.posix.cpp 17 Feb 2005 14:16:29 -0000 1.4 +++ FdListener.posix.cpp 23 Apr 2005 17:47:07 -0000 1.5 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005 by Christian Prochnow * + * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -251,8 +251,10 @@ l->onError(); } + /* seems a bad idea to reset the flags ... we leave it to the + FdListener for now ... if(flags != l->flags()) - l->setFlags(flags); + l->setFlags(flags);*/ } } } Index: FdListener.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/FdListener.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- FdListener.h 10 Feb 2005 19:13:42 -0000 1.2 +++ FdListener.h 23 Apr 2005 17:47:07 -0000 1.3 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005 by Christian Prochnow * + * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -30,14 +30,19 @@ namespace System { +//! Internal file-descriptor listener for POSIX-systems +/*! + This class is used to listen for asynchronous notifications + on file descriptors. +*/ class PSYSTEM_EXPORT FdListener { public: friend class FdListenerList; enum Flags { - Read = 0x01, - Write = 0x02, - Error = 0x04 + Read = 0x01, /*!< Listen for read notifications */ + Write = 0x02, /*!< Listen for write notifications */ + Error = 0x04 /*!< Listen for error notifications */ }; FdListener(int fd, int flags); @@ -49,8 +54,13 @@ void setFlags(int flags) throw(); protected: + //! Called when data is available for reading virtual void onRead(); + + //! Called when ready for writing virtual void onWrite(); + + //! Called on failure notification virtual void onError(); private: |
From: Christian P. <cp...@us...> - 2005-04-23 15:19:45
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20134/include/pclasses/System Modified Files: PathFinder.h Log Message: - Readability and some code cleanup - Removed variable pathSeparator cause it's system specific Index: PathFinder.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/PathFinder.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- PathFinder.h 25 Dec 2004 20:48:13 -0000 1.5 +++ PathFinder.h 23 Apr 2005 15:19:31 -0000 1.6 @@ -1,181 +1,183 @@ -#ifndef p_system_PATHFINDER_H -#define p_system_PATHFINDER_H +#ifndef P_System_PathFinder_h +#define P_System_PathFinder_h + // Author: stephan beal <st...@s1...> // License: Public Domain +// Readability cleanup and code P-ificaton by Christian Prochnow <cp...@se...> +// TODO: get rid of string_list and joinList and tokenize_to_list and provide a common +// implementation as it may be useful for other too. -- cproch +#include <pclasses/Export.h> #include <string> #include <list> #include <map> -#include <iostream> - -// #include <cl/StringList.h> // todo: get rid of this in the public interface. -namespace P { namespace System { - /** - PathFinder searches for keys using a set of prefixes - (paths) and suffixes (file extensions). - - Example: +namespace P { - <pre> - PathFinder p; - p.path( "/lib/lib:/usr/lib/lib" ); - p.extensions( ".a:.so" ); - cout << p.find( "z" ); - </pre> +namespace System { - That would print an empty string if it finds nothing, or a - string if it finds any of the following: +/*! + PathFinder searches for keys using a set of prefixes + (paths) and suffixes (file extensions). + + Example: - - z - - /lib/libz - - /lib/libz.a - - /lib/libz.so - - /usr/lib/libz - - /usr/lib/libz.a - - /usr/lib/libz.so + <pre> + PathFinder p; + p.path( "/lib/lib:/usr/lib/lib" ); + p.extensions( ".a:.so" ); + cout << p.find( "z" ); + </pre> - */ - class PathFinder - { - public: + That would print an empty string if it finds nothing, or a + string if it finds any of the following: - /** - A list type returned by some functions. - */ - typedef std::list<std::string> string_list; + - z + - /lib/libz + - /lib/libz.a + - /lib/libz.so + - /usr/lib/libz + - /usr/lib/libz.a + - /usr/lib/libz.so +*/ +class PSYSTEM_EXPORT PathFinder { + public: /** - Creates object with the given path/extension list. - */ - PathFinder( const std::string & path = std::string(), const std::string & ext = std::string(), const std::string & pathsep = ":" ); + A list type returned by some functions. + */ + typedef std::list<std::string> string_list; - virtual ~PathFinder(); - /** - Returns a ":"-separated string of all paths added via add/path(). - */ - std::string pathString() const; + Creates object with the given path/extension list. + */ + PathFinder(const std::string & path = std::string(), + const std::string & ext = std::string()); - /** - Sets the string used as a separator for the - string-based variants of path(), extentions(), etc. - */ - void pathSeparator( const std::string & sep ); + virtual ~PathFinder(); - /** - Returns the path separator string. Default is ":"; - */ - std::string pathSeparator() const; + /** + Returns a pathSeparator()-delimited string of all paths + added via add/path(). + */ + std::string pathString() const; /** - Sets the path to p, which should be a path_separtor()-delimited string. - Returns the number of path elements parsed from p. - */ + Sets the path to p, which should be a pathSeparator()-delimited string. + Returns the number of path elements parsed from p. + */ virtual size_t path( const std::string & p ); - /** - Sets the path to the given list of directories. - Returns the number of elements in the list. - */ + /** + Sets the path to the given list of directories. + Returns the number of elements in the list. + */ virtual size_t path( const string_list & p ); /** - Adds p to the path. May be path_separtor()-delimited. - */ + Adds p to the path. May be path_separtor()-delimited. + */ virtual void addPath( const std::string & p ); /** - Adds a "search extension." Sample: - finder.extension( ".txt:.TXT" ); Will now try all - path combinations with the rightmost characters - matching ".txt" or ".TXT" (in that order). Be sure - to include a period if you want that searched - - that is so this class can be used to find non-files - and those with non-traditional extensions, like - "foo_EXT". - */ + Adds a "search extension." Sample: + finder.extensions( ".txt:.TXT" ); Will now try all + path combinations with the rightmost characters + matching ".txt" or ".TXT" (in that order). Be sure + to include a period if you want that searched - + that is so this class can be used to find non-files + and those with non-traditional extensions, like + "foo_EXT". + */ virtual void addExtension( const std::string & ext = std::string() ); + /** - like addExtension(), but overwrites extension list. - Returns the number of entries parsed from the string. - */ + like addExtension(), but overwrites extension list. + Returns the number of entries parsed from the string. + */ virtual size_t extensions( const std::string & ext ); - /** - Sets the extensions list to the given list. - Returns the number of entries in p. - */ + + /** + Sets the extensions list to the given list. + Returns the number of entries in p. + */ virtual size_t extensions( const string_list & p ); /** - Returns the pathSeparator()-delimited listed of file - suffixes to use when searching for a path. - */ - std::string extensionsString() const; - /** - Returns this object's extensions list. - */ + Returns the pathSeparator()-delimited listed of file + suffixes to use when searching for a path. + */ + std::string extensionsString() const; + + /** + Returns this object's extensions list. + */ const string_list & extensions() const; - /** - Returns true if path is readable. - */ + /** + Returns true if path is readable. + */ static bool isAccessible( const std::string & path ); /** - Returns the "base name" of the given string: any part - following the final directory separator character. - */ + Returns the "base name" of the given string: any part + following the final directory separator character. + */ static std::string basename( const std::string & ); - /** - Returns a platform-dependent path separator. This - is set when the class is compiled. - */ + /** + Returns a platform-dependent directory separator. This + is set when the class is compiled. + */ static std::string dirSeparator(); /** - Returns the full path of the given resource, provided it could be found - in all paths or with all extensions added and provided it is readable. - Note that this might return a relative path, especially if the - resourcename passed to it immediately resolves to an existing resource. - It returns an empty string if the resourcename cannot be found in - the filesystem tree (or is otherwise unaccessible). + Returns a platform-dependent path-list separator string. + This is set when the class is compiled. + */ + static std::string pathSeparator(); - If check_cache is false then this function ignores - it's lookup cache and searches again, otherwise it - uses a cache. When caching it will always return - the same result for any given resourcename. - */ - std::string find( const std::string & resourcename, bool check_cache = true ) const; + /** + Returns the full path of the given resource, provided it could be found + in all paths or with all extensions added and provided it is readable. + Note that this might return a relative path, especially if the + resourcename passed to it immediately resolves to an existing resource. + It returns an empty string if the resourcename cannot be found in + the filesystem tree (or is otherwise unaccessible). - /** - Empties the hit-cache used by find(). + If check_cache is false then this function ignores + it's lookup cache and searches again, otherwise it + uses a cache. When caching it will always return + the same result for any given resourcename. + */ + std::string find( const std::string & resourcename, bool check_cache = true ) const; - Design note: because the cache is mutable data, we - *could* legally make this function const. Something - to consider. - */ - void clearCache(); + /** + Empties the hit-cache used by find(). + Design note: because the cache is mutable data, we + *could* legally make this function const. Something + to consider. + */ + void clearCache(); /** - Returns a list of all items added via addPath() and path(). - */ + Returns a list of all items added via addPath() and path(). + */ const string_list & path() const; - - private: + private: string_list paths; string_list exts; - std::string pathseparator; typedef std::map < std::string, std::string > StringStringMap; typedef StringStringMap::iterator StringStringIterator; mutable StringStringMap hitcache; - }; +}; +} // !namespace System -} } // namespaces -#endif // p_system_PATHFINDER_H +} // !namespace P + +#endif // !P_System_PathFinder_h |
From: Christian P. <cp...@us...> - 2005-04-23 15:19:44
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20134/src/System Modified Files: PathFinder.cpp Log Message: - Readability and some code cleanup - Removed variable pathSeparator cause it's system specific Index: PathFinder.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/PathFinder.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- PathFinder.cpp 25 Dec 2004 20:48:13 -0000 1.3 +++ PathFinder.cpp 23 Apr 2005 15:19:32 -0000 1.4 @@ -1,7 +1,9 @@ // Author: stephan beal <st...@s1...> // License: Public Domain +// Readability cleanup and code P-ificaton by Christian Prochnow <cp...@se...> #include <iostream> +#include <sstream> #include <stdlib.h> // getenv() @@ -21,139 +23,130 @@ #define CERR std::cerr << __FILE__ << ":" << std::dec << __LINE__ << " : " #endif - - using std::string; using std::ostream; -namespace P { namespace System { +namespace P { +namespace System { - PathFinder::~PathFinder() - { - } - PathFinder::PathFinder( const string & p, const string & e, const string & pathsep ) - { - this->pathSeparator( pathsep ); - this->path( p ); - this->extensions( e ); - } +PathFinder::~PathFinder() +{ +} +PathFinder::PathFinder(const string & p, const string & e) +{ + this->path( p ); + this->extensions( e ); +} - string PathFinder::pathSeparator() const - { - return this->pathseparator; - } +/** + Internal helper function to collapse a list into a string. + cproch: Modified code to use a ostringstream. Appending to strings is really slow. +*/ +template <typename StringList> +std::string joinList( const StringList & list, const std::string & separator ) +{ + std::ostringstream ret; + unsigned long count = list.size(); + unsigned long at = 0; - void PathFinder::pathSeparator( const string & sep ) + typename StringList::const_iterator it = list.begin(); + while(it != list.end()) { - this->pathseparator = sep; + ret << (*it); + ++it; + if(it != list.end()) + ret << separator; } - /** - Internal helper function to collapse a list into a string. - */ - template <typename StringList> - std::string joinList( const StringList & list, const std::string & separator ) - { - std::string ret; - unsigned long count = list.size(); - unsigned long at = 0; - typename StringList::const_iterator it = list.begin(); - typename StringList::const_iterator et = list.end(); - for(; it != et; ++it ) - { - - ret += (*it); - if( ++at != count ) ret += separator; - } - return ret; - } - - string PathFinder::pathString() const - { - return joinList( this->paths, this->pathseparator ); - } + return ret.str(); +} - const PathFinder::string_list & PathFinder::path() const - { - return this->paths; - } +string PathFinder::pathString() const +{ + return joinList( this->paths, pathSeparator() ); +} - string PathFinder::extensionsString() const - { - return joinList( this->exts, this->pathseparator ); - } +const PathFinder::string_list & PathFinder::path() const +{ + return this->paths; +} - const PathFinder::string_list & PathFinder::extensions() const - { - return this->exts; - } +string PathFinder::extensionsString() const +{ + return joinList( this->exts, pathSeparator()); +} +const PathFinder::string_list & PathFinder::extensions() const +{ + return this->exts; +} - size_t tokenize_to_list( const std::string & str, std::list<std::string> & li, const std::string & sep ) - { // internal helper function - if( str.empty() ) return 0; +size_t tokenize_to_list( const std::string & str, std::list<std::string> & li, const std::string & sep ) +{ // internal helper function + if( str.empty() ) return 0; - size_t c = 0; + size_t c = 0; - std::string token; - std::string::size_type sz = str.size(); - for( std::string::size_type i = 0; i < sz; i++ ) - { - if( sz-1 == i ) token += str[i]; - if( str.find( sep, i ) == i || (sz-1 == i) ) - { - //CERR << "token="<<token<<std::endl; - li.push_back( token ); - token = ""; - i += sep.size() - 1; - continue; - } - token += str[i]; - } - return c; - } + std::string token; + std::string::size_type sz = str.size(); - size_t PathFinder::path( const string & p ) + for( std::string::size_type i = 0; i < sz; i++ ) { - this->paths.erase( this->paths.begin(), this->paths.end() ); - return tokenize_to_list( p, this->paths, this->pathseparator ); + if( sz-1 == i ) token += str[i]; + if( str.find( sep, i ) == i || (sz-1 == i) ) + { + //CERR << "token="<<token<<std::endl; + li.push_back( token ); + token = ""; + i += sep.size() - 1; + continue; + } + token += str[i]; } - size_t PathFinder::path( const PathFinder::string_list & p ) - { - this->paths = p; - return this->paths.size(); - } + return c; +} - void PathFinder::addPath( const string & p ) - { - tokenize_to_list( p, this->paths, this->pathseparator ); - } +size_t PathFinder::path( const string & p ) +{ + this->paths.erase( this->paths.begin(), this->paths.end() ); + return tokenize_to_list( p, this->paths, pathSeparator() ); +} +size_t PathFinder::path( const PathFinder::string_list & p ) +{ + this->paths = p; + return this->paths.size(); +} - size_t PathFinder::extensions( const string & p ) - { - this->exts.erase( this->exts.begin(), this->exts.end() ); - return tokenize_to_list( p, this->exts, this->pathseparator ); - } +void PathFinder::addPath( const string & p ) +{ + tokenize_to_list( p, this->paths, pathSeparator() ); +} - size_t PathFinder::extensions( const PathFinder::string_list & e ) - { - this->exts = e; - return this->exts.size(); - } +size_t PathFinder::extensions( const string & p ) +{ + this->exts.erase( this->exts.begin(), this->exts.end() ); + return tokenize_to_list( p, this->exts, pathSeparator() ); +} - void PathFinder::addExtension( const string & p ) - { - tokenize_to_list( p, this->exts, this->pathseparator ); - } +size_t PathFinder::extensions( const PathFinder::string_list & e ) +{ + this->exts = e; + return this->exts.size(); +} - // static - bool PathFinder::isAccessible( const string & path ) - { +void PathFinder::addExtension( const string & p ) +{ + tokenize_to_list( p, this->exts, pathSeparator() ); +} + +// static +bool PathFinder::isAccessible( const string & path ) +{ #if WIN32 # define CHECKACCESS _access # define CHECKRIGHTS 0 @@ -162,91 +155,105 @@ # define CHECKRIGHTS F_OK #endif - return 0 == CHECKACCESS( path.c_str(), CHECKRIGHTS ); + return 0 == CHECKACCESS( path.c_str(), CHECKRIGHTS ); #undef CHECKACCESS #undef CHECKRIGHTS - } +} - string PathFinder::basename( const std::string & name ) - { - string::size_type slashat = name.find_last_of( PathFinder::dirSeparator() ); - if ( slashat == string::npos ) - return name; - return name.substr( slashat + 1 ); - } +string PathFinder::basename( const std::string & name ) +{ + string::size_type slashat = name.find_last_of( PathFinder::dirSeparator() ); + if ( slashat == string::npos ) + return name; + return name.substr( slashat + 1 ); +} +std::string PathFinder::dirSeparator() +{ +#ifdef WIN32 + return std::string( "\\" ); +#else + return std::string( "/" ); +#endif +} - std::string PathFinder::dirSeparator() - { -#if WIN32 - return std::string( "\\" ); +std::string PathFinder::pathSeparator() +{ +#ifdef WIN32 + return std::string( ";" ); #else - return std::string( "/" ); + return std::string( ":" ); #endif - } +} - string PathFinder::find( const string & resource, bool check_cache ) const - { - //static const std::string NOT_FOUND = "PathFinder::find() : no findie"; - if( resource.empty() ) return resource; +string PathFinder::find( const string & resource, bool check_cache ) const +{ + //static const std::string NOT_FOUND = "PathFinder::find() : no findie"; + if( resource.empty() ) return resource; #define CHECKPATH(CHECKAT) \ - if( ! CHECKAT.empty() && PathFinder::isAccessible( CHECKAT ) ) \ - { this->hitcache[resource] = CHECKAT; return CHECKAT; } + if( ! CHECKAT.empty() && PathFinder::isAccessible( CHECKAT ) ) \ + { this->hitcache[resource] = CHECKAT; return CHECKAT; } - //CERR << "find( " << resource << " )" << std::endl; - if( check_cache ) - { - std::map <std::string,std::string>::iterator mapiter; - mapiter = this->hitcache.find( resource ); - if( this->hitcache.end() != mapiter ) return (*mapiter).second; - } + //CERR << "find( " << resource << " )" << std::endl; + if(check_cache) + { + std::map <std::string,std::string>::iterator mapiter; + mapiter = this->hitcache.find( resource ); + if( this->hitcache.end() != mapiter ) return (*mapiter).second; + } - CHECKPATH( resource ); + CHECKPATH( resource ); - string_list::const_iterator piter = this->paths.begin(); - string_list::const_iterator eiter = this->exts.begin(); + string_list::const_iterator piter = this->paths.begin(); + string_list::const_iterator eiter = this->exts.begin(); - string path; - string ext; + string path; + string ext; - if ( PathFinder::isAccessible( resource ) ) - return resource; + if ( PathFinder::isAccessible( resource ) ) + return resource; - piter = this->paths.begin(); - string checkhere; - while ( piter != this->paths.end() ) + piter = this->paths.begin(); + string checkhere; + + while ( piter != this->paths.end() ) + { + path = ( *piter ); + if ( !path.empty() ) { - path = ( *piter ); - if ( !path.empty() ) - { - path += PathFinder::dirSeparator(); - } - ++piter; - checkhere = path + resource; + path += PathFinder::dirSeparator(); + } + + ++piter; + checkhere = path + resource; + + //CERR << "find( " << resource << " ) checking " << checkhere << std::endl; + CHECKPATH( checkhere ); + + eiter = this->exts.begin(); + while ( eiter != this->exts.end() ) + { + ext = ( *eiter ); + ++eiter; + checkhere = path + resource + ext; //CERR << "find( " << resource << " ) checking " << checkhere << std::endl; CHECKPATH( checkhere ); - eiter = this->exts.begin(); - while ( eiter != this->exts.end() ) - { - ext = ( *eiter ); - ++eiter; - checkhere = path + resource + ext; - //CERR << "find( " << resource << " ) checking " << checkhere << std::endl; - CHECKPATH( checkhere ); - } } - //CERR << "find( "<<resource<<" ): not found :(" << std::endl; - // so arguable: - // this->hitcache[resource] = ""; - return string(); } - void PathFinder::clearCache() - { - this->hitcache.clear(); - } + //CERR << "find( "<<resource<<" ): not found :(" << std::endl; + // so arguable: + // this->hitcache[resource] = ""; + return string(); +} + +void PathFinder::clearCache() +{ + this->hitcache.clear(); +} + // /** // bin_PathFinder is a PathFinder which uses the environment's PATH by default. // */ @@ -269,4 +276,6 @@ // } -}} // namespaces +} // !namespace System + +} // !namespace P |
From: Christian P. <cp...@us...> - 2005-04-23 12:00:15
|
Update of /cvsroot/pclasses/pclasses2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9938 Modified Files: configure.in Log Message: Added configure check for native atomic integers Index: configure.in =================================================================== RCS file: /cvsroot/pclasses/pclasses2/configure.in,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- configure.in 19 Jan 2005 13:25:55 -0000 1.8 +++ configure.in 23 Apr 2005 12:00:06 -0000 1.9 @@ -70,6 +70,36 @@ AC_FUNC_MMAP dnl +dnl check cpu/compiler type for atomicint support ... +dnl + +AC_MSG_CHECKING([for native atomic int support ...]) +pc_atomic_int="none" + +AC_TRY_COMPILE([], [ + int val; + unsigned char c; + __asm__ __volatile__( + "lock; incl %0; sete %1" + :"=m" (val), "=qm" (c) + :"m" (val) : "memory"); +], pc_atomic_int="gcc_x86") + +AC_TRY_COMPILE([#include <windows.h>], [ + int val; + InterlockedIncrement((volatile LONG*)val); +], pc_atomic_int="win32") + +AC_MSG_RESULT($pc_atomic_int) + +AM_CONDITIONAL(WITH_GCC_X86_ATOMIC_INT, test "$pc_atomic_int" = "gcc_x86") +AM_CONDITIONAL(WITH_WIN32_ATOMIC_INT, test "$pc_atomic_int" = "win32") + +if test "$pc_atomic_int" != "none"; then + AC_DEFINE_UNQUOTED(HAVE_ATOMIC_INT, 1, [Defined if atomic integers are supported]) +fi + +dnl dnl check for threading libraries dnl ACX_PTHREAD |
From: Christian P. <cp...@us...> - 2005-04-23 12:00:14
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9938/src Modified Files: Makefile.am Log Message: Added configure check for native atomic integers Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Makefile.am,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Makefile.am 7 Feb 2005 18:45:15 -0000 1.7 +++ Makefile.am 23 Apr 2005 12:00:06 -0000 1.8 @@ -7,10 +7,31 @@ CPPFLAGS = -DPCORE_BUILD +if WITH_POSIX_THREADS +Thread_Sources = AtomicMutex.posix.cpp +endif + +if WITH_SOLARIS_THREADS +Thread_Sources = AtomicMutex.solaris.cpp +endif + +if WITH_WIN32_THREADS +Thread_Sources = AtomicMutex.win32.cpp +endif + +if WITH_GCC_X86_ATOMIC_INT +Atomic_Sources = AtomicInt.gcc-x86.cpp +endif + +if WITH_WIN32_ATOMIC_INT +Atomic_Sources = AtomicInc.win32.cpp +endif + libpclasses_la_LDFLAGS = -no-undefined -libpclasses_la_SOURCES = Alloc.cpp Exception.cpp AtomicInt.gcc-x86.cpp \ +libpclasses_la_SOURCES = Alloc.cpp Exception.cpp \ ByteOrderTraits.cpp LinkedItem.cpp Time.cpp Date.cpp DateTime.cpp \ - TimeSpan.cpp Trace.cpp Callback.cpp + TimeSpan.cpp Trace.cpp Callback.cpp \ + $(Thread_Sources) $(Atomic_Sources) SUBDIRS = . Unicode IO System Net Util XML App |
From: Christian P. <cp...@us...> - 2005-04-23 11:59:19
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9449/src Modified Files: AtomicMutex.posix.cpp AtomicMutex.win32.cpp Log Message: Moved AtomicTraits<Type>::Mutex to AtomicMutex Index: AtomicMutex.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/AtomicMutex.posix.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- AtomicMutex.posix.cpp 23 Apr 2005 10:54:45 -0000 1.1 +++ AtomicMutex.posix.cpp 23 Apr 2005 11:59:08 -0000 1.2 @@ -25,35 +25,35 @@ namespace Traits { -AtomicTraits::Mutex() +AtomicMutex::AtomicMutex() : _handle((unsigned long)new pthread_mutex_t) { pthread_mutex_init((pthread_mutex_t*)_handle, 0); } -AtomicTraits::~Mutex() +AtomicMutex::~AtomicMutex() { pthread_mutex_destroy((pthread_mutex_t*)_handle); delete (pthread_mutex_t*)_handle; } -void AtomicTraits::Mutex::lock() throw() +void AtomicMutex::lock() throw() { pthread_mutex_lock((pthread_mutex_t*)_handle); } -void AtomicTraits::Mutex::unlock() throw() +void AtomicMutex::unlock() throw() { pthread_mutex_unlock((pthread_mutex_t*)_handle); } -AtomicTraits::Mutex::ScopedLock(Mutex& mtx) +AtomicMutex::ScopedLock::ScopedLock(AtomicMutex& mtx) : _mtx(mtx) { _mtx.lock(); } -AtomicTraits::Mutex::~ScopedLock() +AtomicMutex::ScopedLock::~ScopedLock() { _mtx.unlock(); } Index: AtomicMutex.win32.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/AtomicMutex.win32.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- AtomicMutex.win32.cpp 23 Apr 2005 10:54:45 -0000 1.1 +++ AtomicMutex.win32.cpp 23 Apr 2005 11:59:08 -0000 1.2 @@ -25,35 +25,35 @@ namespace Traits { -AtomicTraits::Mutex() +AtomicMutex::AtomicMutex() : _handle((unsigned long)new CRITICAL_SECTION) { InitializeCriticalSection((CRITICAL_SECTION*)_handle)); } -AtomicTraits::~Mutex() +AtomicMutex::~AtomicMutex() { DeleteCriticalSection((CRITICAL_SECTION*)_handle)); delete (CRITICAL_SECTION*)_handle; } -void AtomicTraits::Mutex::lock() throw() +void AtomicMutex::lock() throw() { EnterCriticalSection((CRITICAL_SECTION*)_handle)); } -void AtomicTraits::Mutex::unlock() throw() +void AtomicMutex::unlock() throw() { LeaveCriticalSection((CRITICAL_SECTION*)_handle)); } -AtomicTraits::Mutex::ScopedLock(Mutex& mtx) +AtomicMutex::ScopedLock::ScopedLock(AtomicMutex& mtx) : _mtx(mtx) { _mtx.lock(); } -AtomicTraits::Mutex::~ScopedLock() +AtomicMutex::ScopedLock::~ScopedLock() { _mtx.unlock(); } |
From: Christian P. <cp...@us...> - 2005-04-23 11:59:19
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9449/include/pclasses Modified Files: AtomicTraits.h Log Message: Moved AtomicTraits<Type>::Mutex to AtomicMutex Index: AtomicTraits.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/AtomicTraits.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- AtomicTraits.h 23 Apr 2005 10:54:45 -0000 1.4 +++ AtomicTraits.h 23 Apr 2005 11:59:08 -0000 1.5 @@ -27,6 +27,34 @@ namespace Traits { +//! AtomicMutex +/*! + The AtomicMutex class is used by the default implementation of + AtomicTraits<> to provide atomicity for types that dont have a + AtomicTraits specialisation. +*/ +class PCORE_EXPORT AtomicMutex { + public: + AtomicMutex(); + ~AtomicMutex(); + + void lock() throw(); + void unlock() throw(); + + class ScopedLock { + public: + ScopedLock(AtomicMutex& mtx); + ~ScopedLock(); + + private: + AtomicMutex& _mtx; + }; + + private: + unsigned long _handle; +}; + + //! Atomic traits /*! The AtomicTraits template supplies the actual implementation for the @@ -38,77 +66,49 @@ template <class Type> struct AtomicTraits { - //! AtomicTraits Mutex - /*! - The Mutex class is used by the default implementation of - AtomicTraits<> to provide atomicity for types that dont have a - AtomicTraits specialisation. - */ - class Mutex { - public: - Mutex(); - ~Mutex(); - - void lock() throw(); - void unlock() throw(); - - class ScopedLock { - public: - ScopedLock(Mutex& mtx); - ~ScopedLock(); - - private: - Mutex& _mtx; - }; - - private: - unsigned long _handle; - }; - struct AtomicType { Type value; - Mutex lock; + AtomicMutex lock; }; static void set(AtomicType* atomic, const Type& val) throw() { - Mutex::ScopedLock lck(atomic->lock); + AtomicMutex::ScopedLock lck(atomic->lock); atomic->value = val; } static Type get(const AtomicType* atomic) throw() { - Mutex::ScopedLock lck(atomic->lock); + AtomicMutex::ScopedLock lck(atomic->lock); return atomic->value; } static void inc(AtomicType* val) throw() { - Mutex::ScopedLock lck(val->lock); + AtomicMutex::ScopedLock lck(val->lock); ++val->value; } static bool incAndTest(AtomicType* val) throw() { - Mutex::ScopedLock lck(val->lock); + AtomicMutex::ScopedLock lck(val->lock); return !(++val->value); } static void dec(AtomicType* val) throw() { - Mutex::ScopedLock lck(val->lock); + AtomicMutex::ScopedLock lck(val->lock); --val->value; } static bool decAndTest(AtomicType* val) throw() { - Mutex::ScopedLock lck(val->lock); + AtomicMutex::ScopedLock lck(val->lock); return !(--val->value); } }; -//@todo this comes from pclasses-config.h -//#ifdef PCLASSES_HAVE_ATOMIC_INT +#ifdef PCLASSES_HAVE_ATOMIC_INT //! Atomic integer type-traits template <> struct PCORE_EXPORT AtomicTraits<int> { @@ -123,7 +123,7 @@ static void dec(int* atomic) throw(); static bool decAndTest(int* atomic) throw(); }; -//#endif +#endif } // !namespace Traits |
From: Christian P. <cp...@us...> - 2005-04-23 10:54:56
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7503/include/pclasses Modified Files: Atomic.h AtomicTraits.h Log Message: Added AtomicMutex in favor of System::CriticalSection to get rid of dependency on System. Index: AtomicTraits.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/AtomicTraits.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- AtomicTraits.h 20 Jan 2005 22:42:30 -0000 1.3 +++ AtomicTraits.h 23 Apr 2005 10:54:45 -0000 1.4 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004 by Christian Prochnow * + * Copyright (C) 2004,2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -22,53 +22,87 @@ #define P_AtomicTraits_h #include <pclasses/Export.h> -#include <pclasses/System/CriticalSection.h> namespace P { namespace Traits { -//! Atomic type-traits +//! Atomic traits +/*! + The AtomicTraits template supplies the actual implementation for the + atomic operations that can be used via the Atomic<> template class. + The default implementation uses a mutex to provide the atomicity, + while the type-specialized implementations will use real atomic + operations. +*/ template <class Type> struct AtomicTraits { + + //! AtomicTraits Mutex + /*! + The Mutex class is used by the default implementation of + AtomicTraits<> to provide atomicity for types that dont have a + AtomicTraits specialisation. + */ + class Mutex { + public: + Mutex(); + ~Mutex(); + + void lock() throw(); + void unlock() throw(); + + class ScopedLock { + public: + ScopedLock(Mutex& mtx); + ~ScopedLock(); + + private: + Mutex& _mtx; + }; + + private: + unsigned long _handle; + }; + struct AtomicType { Type value; - System::CriticalSection lock; + Mutex lock; }; static void set(AtomicType* atomic, const Type& val) throw() { - System::CriticalSection::ScopedLock lck(atomic->lock); + Mutex::ScopedLock lck(atomic->lock); atomic->value = val; } static Type get(const AtomicType* atomic) throw() { - System::CriticalSection::ScopedLock lck(atomic->lock); + Mutex::ScopedLock lck(atomic->lock); return atomic->value; } static void inc(AtomicType* val) throw() { - System::CriticalSection::ScopedLock lck(val->lock); + Mutex::ScopedLock lck(val->lock); ++val->value; } static bool incAndTest(AtomicType* val) throw() { - System::CriticalSection::ScopedLock lck(val->lock); + Mutex::ScopedLock lck(val->lock); return !(++val->value); } static void dec(AtomicType* val) throw() { - System::CriticalSection::ScopedLock lck(val->lock); + Mutex::ScopedLock lck(val->lock); --val->value; } static bool decAndTest(AtomicType* val) throw() { - System::CriticalSection::ScopedLock lck(val->lock); + Mutex::ScopedLock lck(val->lock); return !(--val->value); } }; Index: Atomic.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Atomic.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- Atomic.h 22 Dec 2004 17:54:40 -0000 1.1.1.1 +++ Atomic.h 23 Apr 2005 10:54:45 -0000 1.2 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004 by Christian Prochnow * + * Copyright (C) 2004,2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -18,14 +18,19 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _P_Atomic_h_ -#define _P_Atomic_h_ +#ifndef P_Atomic_h +#define P_Atomic_h #include <pclasses/AtomicTraits.h> namespace P { //! Atomic value-type template +/*! + The Atomic value template class provides limited atomic operations for + a given value type. Atomic operations are synchronised across all + threads in the system. +*/ template <class Type> class Atomic { public: @@ -33,35 +38,49 @@ typedef Traits::AtomicTraits<Type> TraitsType; typedef typename Traits::AtomicTraits<Type>::AtomicType AtomicType; + //! Constructor Atomic(const Type& val = Type()) throw() { TraitsType::set(&_val, val); } + //! Destructor ~Atomic() throw() { } + //! Returns the value operator Type() const throw() { return TraitsType::get(&_val); } + //! Increment and test for zero + /*! + Increments the stored value and returns true if the value + has become zero, and false otherwise. + */ bool operator++() throw() { return TraitsType::incAndTest(&_val); } + //! Increment the value void operator++(int) throw() { TraitsType::inc(&_val); } + //! Decrement and test for zero + /*! + Decrements the stored value and returns true if the value + has become zero, and false otherwise. + */ bool operator--() throw() { return TraitsType::decAndTest(&_val); } + //! Decrement the value void operator--(int) throw() { TraitsType::dec(&_val); } + //! Assign new value Atomic& operator=(int val) throw() { TraitsType::set(&_val, val); return *this; } - //@todo deny all other operators - private: AtomicType _val; }; |
From: Christian P. <cp...@us...> - 2005-04-23 10:54:54
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7503/src Added Files: AtomicMutex.posix.cpp AtomicMutex.win32.cpp Log Message: Added AtomicMutex in favor of System::CriticalSection to get rid of dependency on System. --- NEW FILE: AtomicMutex.posix.cpp --- /*************************************************************************** * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "pclasses/AtomicTraits.h" #include <pthread.h> namespace P { namespace Traits { AtomicTraits::Mutex() : _handle((unsigned long)new pthread_mutex_t) { pthread_mutex_init((pthread_mutex_t*)_handle, 0); } AtomicTraits::~Mutex() { pthread_mutex_destroy((pthread_mutex_t*)_handle); delete (pthread_mutex_t*)_handle; } void AtomicTraits::Mutex::lock() throw() { pthread_mutex_lock((pthread_mutex_t*)_handle); } void AtomicTraits::Mutex::unlock() throw() { pthread_mutex_unlock((pthread_mutex_t*)_handle); } AtomicTraits::Mutex::ScopedLock(Mutex& mtx) : _mtx(mtx) { _mtx.lock(); } AtomicTraits::Mutex::~ScopedLock() { _mtx.unlock(); } } // !namespace Traits } // !namespace P --- NEW FILE: AtomicMutex.win32.cpp --- /*************************************************************************** * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "pclasses/AtomicTraits.h" #include <windows.h> namespace P { namespace Traits { AtomicTraits::Mutex() : _handle((unsigned long)new CRITICAL_SECTION) { InitializeCriticalSection((CRITICAL_SECTION*)_handle)); } AtomicTraits::~Mutex() { DeleteCriticalSection((CRITICAL_SECTION*)_handle)); delete (CRITICAL_SECTION*)_handle; } void AtomicTraits::Mutex::lock() throw() { EnterCriticalSection((CRITICAL_SECTION*)_handle)); } void AtomicTraits::Mutex::unlock() throw() { LeaveCriticalSection((CRITICAL_SECTION*)_handle)); } AtomicTraits::Mutex::ScopedLock(Mutex& mtx) : _mtx(mtx) { _mtx.lock(); } AtomicTraits::Mutex::~ScopedLock() { _mtx.unlock(); } } // !namespace Traits } // !namespace P |
From: stephan b. <sg...@us...> - 2005-03-12 14:57:50
|
Update of /cvsroot/pclasses/pclasses2/src/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9535 Modified Files: StringTool.cpp Log Message: corrected potential segfault in the new trimRight() code. Index: StringTool.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Util/StringTool.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- StringTool.cpp 12 Mar 2005 14:54:50 -0000 1.10 +++ StringTool.cpp 12 Mar 2005 14:57:40 -0000 1.11 @@ -413,6 +413,7 @@ void trimRight(std::string& str) { std::string::size_type nw = str.find_last_not_of(" \t\n\r"); + if( std::string::npos == nw ) return; str.erase(nw+1); } |
From: stephan b. <sg...@us...> - 2005-03-12 14:55:11
|
Update of /cvsroot/pclasses/pclasses2/src/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8777 Modified Files: StringTool.cpp Log Message: corrected a missing & on trim(string&) Index: StringTool.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Util/StringTool.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- StringTool.cpp 10 Jan 2005 12:58:05 -0000 1.9 +++ StringTool.cpp 12 Mar 2005 14:54:50 -0000 1.10 @@ -416,7 +416,7 @@ str.erase(nw+1); } -void trim(std::string str) +void trim(std::string & str) { trimLeft(str); trimRight(str); |