trunk/branch integration: new files

This commit is contained in:
Marian Krivos 2011-08-22 19:56:17 +00:00
parent 10b2a566f9
commit d652a7b2fa
8 changed files with 764 additions and 0 deletions

View File

@ -0,0 +1,71 @@
//
// Event_VX.h
//
// $Id: //poco/1.4/Foundation/include/Poco/Event_VX.h#1 $
//
// Library: Foundation
// Package: Threading
// Module: Event
//
// Definition of the EventImpl class for VxWorks.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Foundation_Event_VX_INCLUDED
#define Foundation_Event_VX_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/Exception.h"
#include <semLib.h>
namespace Poco {
class Foundation_API EventImpl
{
protected:
EventImpl(bool autoReset);
~EventImpl();
void setImpl();
void waitImpl();
bool waitImpl(long milliseconds);
void resetImpl();
private:
bool _auto;
volatile bool _state;
SEM_ID _sem;
};
} // namespace Poco
#endif // Foundation_Event_VX_INCLUDED

View File

@ -0,0 +1,102 @@
//
// Mutex_VX.h
//
// $Id: //poco/1.4/Foundation/include/Poco/Mutex_VX.h#1 $
//
// Library: Foundation
// Package: Threading
// Module: Mutex
//
// Definition of the MutexImpl and FastMutexImpl classes for VxWorks.
//
// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Foundation_Mutex_VX_INCLUDED
#define Foundation_Mutex_VX_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/Exception.h"
#include <semLib.h>
#include <errno.h>
namespace Poco {
class Foundation_API MutexImpl
{
protected:
MutexImpl();
MutexImpl(bool fast);
~MutexImpl();
void lockImpl();
bool tryLockImpl();
bool tryLockImpl(long milliseconds);
void unlockImpl();
private:
SEM_ID _sem;
};
class Foundation_API FastMutexImpl: public MutexImpl
{
protected:
FastMutexImpl();
~FastMutexImpl();
};
//
// inlines
//
inline void MutexImpl::lockImpl()
{
if (semTake(_sem, WAIT_FOREVER) != OK)
throw SystemException("cannot lock mutex");
}
inline bool MutexImpl::tryLockImpl()
{
return semTake(_sem, NO_WAIT) == OK;
}
inline void MutexImpl::unlockImpl()
{
if (semGive(_sem) != OK)
throw SystemException("cannot unlock mutex");
}
} // namespace Poco
#endif // Foundation_Mutex_VX_INCLUDED

View File

@ -0,0 +1,62 @@
//
// NamedEvent_Android.h
//
// $Id: //poco/1.4/Foundation/include/Poco/NamedEvent_Android.h#1 $
//
// Library: Foundation
// Package: Processes
// Module: NamedEvent
//
// Definition of the NamedEventImpl class for Android.
//
// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Foundation_NamedEvent_Android_INCLUDED
#define Foundation_NamedEvent_Android_INCLUDED
#include "Poco/Foundation.h"
namespace Poco {
class Foundation_API NamedEventImpl
{
protected:
NamedEventImpl(const std::string& name);
~NamedEventImpl();
void setImpl();
void waitImpl();
};
} // namespace Poco
#endif // Foundation_NamedEvent_Android_INCLUDED

View File

@ -0,0 +1,63 @@
//
// NamedMutex_Android.h
//
// $Id: //poco/1.4/Foundation/include/Poco/NamedMutex_Android.h#1 $
//
// Library: Foundation
// Package: Processes
// Module: NamedMutex
//
// Definition of the NamedMutexImpl class for Android.
//
// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Foundation_NamedMutex_Android_INCLUDED
#define Foundation_NamedMutex_Android_INCLUDED
#include "Poco/Foundation.h"
namespace Poco {
class Foundation_API NamedMutexImpl
{
protected:
NamedMutexImpl(const std::string& name);
~NamedMutexImpl();
void lockImpl();
bool tryLockImpl();
void unlockImpl();
};
} // namespace Poco
#endif // Foundation_NamedMutex_Android_INCLUDED

View File

@ -0,0 +1,119 @@
//
// RWLock_Android.h
//
// $Id: //poco/1.4/Foundation/include/Poco/RWLock_Android.h#1 $
//
// Library: Foundation
// Package: Threading
// Module: RWLock
//
// Definition of the RWLockImpl class for Android Threads.
//
// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Foundation_RWLock_Android_INCLUDED
#define Foundation_RWLock_Android_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/Exception.h"
#include <pthread.h>
#include <errno.h>
namespace Poco {
class Foundation_API RWLockImpl
{
protected:
RWLockImpl();
~RWLockImpl();
void readLockImpl();
bool tryReadLockImpl();
void writeLockImpl();
bool tryWriteLockImpl();
void unlockImpl();
private:
pthread_mutex_t _mutex;
};
//
// inlines
//
inline void RWLockImpl::readLockImpl()
{
if (pthread_mutex_lock(&_mutex))
throw SystemException("cannot lock reader/writer lock");
}
inline bool RWLockImpl::tryReadLockImpl()
{
int rc = pthread_mutex_trylock(&_mutex);
if (rc == 0)
return true;
else if (rc == EBUSY)
return false;
else
throw SystemException("cannot lock reader/writer lock");
}
inline void RWLockImpl::writeLockImpl()
{
if (pthread_mutex_lock(&_mutex))
throw SystemException("cannot lock reader/writer lock");
}
inline bool RWLockImpl::tryWriteLockImpl()
{
int rc = pthread_mutex_trylock(&_mutex);
if (rc == 0)
return true;
else if (rc == EBUSY)
return false;
else
throw SystemException("cannot lock reader/writer lock");
}
inline void RWLockImpl::unlockImpl()
{
if (pthread_mutex_unlock(&_mutex))
throw SystemException("cannot unlock reader/writer lock");
}
} // namespace Poco
#endif // Foundation_RWLock_Android_INCLUDED

View File

@ -0,0 +1,83 @@
//
// RWLock_WINCE.h
//
// $Id: //poco/1.4/Foundation/include/Poco/RWLock_WINCE.h#1 $
//
// Library: Foundation
// Package: Threading
// Module: RWLock
//
// Definition of the RWLockImpl class for WINCE.
//
// Copyright (c) 2009-2010, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Foundation_RWLock_WINCE_INCLUDED
#define Foundation_RWLock_WINCE_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/Exception.h"
#include "Poco/UnWindows.h"
namespace Poco {
class Foundation_API RWLockImpl
/// This implementation is based on the one from Stone Steps Inc,
/// licensed under the BSD license.
/// http://forums.stonesteps.ca/thread.asp?t=105
///
/// Note that with this implementation, writers always take
/// precedence over readers.
{
protected:
RWLockImpl();
~RWLockImpl();
void readLockImpl();
bool tryReadLockImpl(DWORD timeout = 1);
void writeLockImpl();
bool tryWriteLockImpl(DWORD timeout = 1);
void unlockImpl();
private:
DWORD _readerCount;
DWORD _readerWaiting;
DWORD _writerCount;
DWORD _writerWaiting;
HANDLE _readerGreen;
HANDLE _writerGreen;
CRITICAL_SECTION _cs;
bool _writeLock;
};
} // namespace Poco
#endif // Foundation_RWLock_WINCE_INCLUDED

View File

@ -0,0 +1,78 @@
//
// Semaphore_VX.h
//
// $Id: //poco/1.4/Foundation/include/Poco/Semaphore_VX.h#1 $
//
// Library: Foundation
// Package: Threading
// Module: Semaphore
//
// Definition of the SemaphoreImpl class for VxWorks.
//
// Copyright (c) 2004-20011, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Foundation_Semaphore_VX_INCLUDED
#define Foundation_Semaphore_VX_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/Exception.h"
#include <semLib.h>
namespace Poco {
class Foundation_API SemaphoreImpl
{
protected:
SemaphoreImpl(int n, int max);
~SemaphoreImpl();
void setImpl();
void waitImpl();
bool waitImpl(long milliseconds);
private:
SEM_ID _sem;
};
//
// inlines
//
inline void SemaphoreImpl::setImpl()
{
if (semGive(_sem) != OK)
throw SystemException("cannot signal semaphore");
}
} // namespace Poco
#endif // Foundation_Semaphore_VX_INCLUDED

View File

@ -0,0 +1,186 @@
//
// Thread_VX.h
//
// $Id: //poco/1.4/Foundation/include/Poco/Thread_VX.h#1 $
//
// Library: Foundation
// Package: Threading
// Module: Thread
//
// Definition of the ThreadImpl class for VxWorks tasks.
//
// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Foundation_Thread_VX_INCLUDED
#define Foundation_Thread_VX_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/Runnable.h"
#include "Poco/SignalHandler.h"
#include "Poco/Event.h"
#include "Poco/RefCountedObject.h"
#include "Poco/AutoPtr.h"
#include <taskLib.h>
#include <taskVarLib.h>
namespace Poco {
class Foundation_API ThreadImpl
{
public:
typedef int TIDImpl;
typedef void (*Callable)(void*);
enum Priority
{
PRIO_LOWEST_IMPL,
PRIO_LOW_IMPL,
PRIO_NORMAL_IMPL,
PRIO_HIGH_IMPL,
PRIO_HIGHEST_IMPL
};
enum
{
DEFAULT_THREAD_STACK_SIZE = 65536
};
struct CallbackData: public RefCountedObject
{
CallbackData(): callback(0), pData(0)
{
}
Callable callback;
void* pData;
};
ThreadImpl();
~ThreadImpl();
TIDImpl tidImpl() const;
void setPriorityImpl(int prio);
int getPriorityImpl() const;
void setOSPriorityImpl(int prio);
int getOSPriorityImpl() const;
static int getMinOSPriorityImpl();
static int getMaxOSPriorityImpl();
void setStackSizeImpl(int size);
int getStackSizeImpl() const;
void startImpl(Runnable& target);
void startImpl(Callable target, void* pData = 0);
void joinImpl();
bool joinImpl(long milliseconds);
bool isRunningImpl() const;
static void sleepImpl(long milliseconds);
static void yieldImpl();
static ThreadImpl* currentImpl();
static TIDImpl currentTidImpl();
protected:
static void runnableEntry(void* pThread, int, int, int, int, int, int, int, int, int);
static void callableEntry(void* pThread, int, int, int, int, int, int, int, int, int);
static int mapPrio(int prio);
static int reverseMapPrio(int osPrio);
struct ThreadData: public RefCountedObject
{
ThreadData():
pRunnableTarget(0),
pCallbackTarget(0),
task(0),
prio(PRIO_NORMAL_IMPL),
osPrio(0),
done(false),
stackSize(POCO_THREAD_STACK_SIZE)
{
}
Runnable* pRunnableTarget;
AutoPtr<CallbackData> pCallbackTarget;
int task;
int prio;
int osPrio;
Event done;
int stackSize;
};
private:
AutoPtr<ThreadData> _pData;
static ThreadImpl* _pCurrent;
};
//
// inlines
//
inline int ThreadImpl::getPriorityImpl() const
{
return _pData->prio;
}
inline int ThreadImpl::getOSPriorityImpl() const
{
return _pData->osPrio;
}
inline bool ThreadImpl::isRunningImpl() const
{
return _pData->pRunnableTarget != 0 ||
(_pData->pCallbackTarget.get() != 0 && _pData->pCallbackTarget->callback != 0);
}
inline void ThreadImpl::yieldImpl()
{
taskDelay(0);
}
inline int ThreadImpl::getStackSizeImpl() const
{
return _pData->stackSize;
}
inline ThreadImpl::TIDImpl ThreadImpl::tidImpl() const
{
return _pData->task;
}
} // namespace Poco
#endif // Foundation_Thread_VX_INCLUDED