mirror of
https://github.com/pocoproject/poco.git
synced 2025-05-29 07:25:53 +02:00
trunk/branch integration: compile fix
This commit is contained in:
parent
5950201733
commit
8fc17fecfa
@ -350,9 +350,9 @@ void FileChannel::setPurgeCount(const std::string& count)
|
|||||||
std::string::const_iterator it = count.begin();
|
std::string::const_iterator it = count.begin();
|
||||||
std::string::const_iterator end = count.end();
|
std::string::const_iterator end = count.end();
|
||||||
|
|
||||||
while (it != end && std::isspace(*it)) ++it;
|
while (it != end && Ascii::isSpace(*it)) ++it;
|
||||||
while (it != end && std::isdigit(*it)) { n *= 10; n += *it++ - '0'; }
|
while (it != end && Ascii::isDigit(*it)) { n *= 10; n += *it++ - '0'; }
|
||||||
while (it != end && std::isspace(*it)) ++it;
|
while (it != end && Ascii::isSpace(*it)) ++it;
|
||||||
|
|
||||||
if (0 == n)
|
if (0 == n)
|
||||||
throw InvalidArgumentException("Zero is not valid purge count.");
|
throw InvalidArgumentException("Zero is not valid purge count.");
|
||||||
|
@ -43,8 +43,6 @@
|
|||||||
#include "Poco/Timestamp.h"
|
#include "Poco/Timestamp.h"
|
||||||
#include "Poco/Timezone.h"
|
#include "Poco/Timezone.h"
|
||||||
#include "Poco/Environment.h"
|
#include "Poco/Environment.h"
|
||||||
#include <cstdio>
|
|
||||||
#include <cctype>
|
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@ -74,7 +72,7 @@ PatternFormatter::~PatternFormatter()
|
|||||||
|
|
||||||
void PatternFormatter::format(const Message& msg, std::string& text)
|
void PatternFormatter::format(const Message& msg, std::string& text)
|
||||||
{
|
{
|
||||||
Timestamp timestamp = msg.getTime();
|
Timestamp timestamp = msg.getTime();
|
||||||
if (_localTime)
|
if (_localTime)
|
||||||
{
|
{
|
||||||
timestamp += Timezone::utcOffset()*Timestamp::resolution();
|
timestamp += Timezone::utcOffset()*Timestamp::resolution();
|
||||||
|
@ -1,205 +1,210 @@
|
|||||||
//
|
//
|
||||||
// PriorityNotificationQueue.cpp
|
// PriorityNotificationQueue.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/src/PriorityNotificationQueue.cpp#1 $
|
// $Id: //poco/Main/Foundation/src/PriorityNotificationQueue.cpp#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Notifications
|
// Package: Notifications
|
||||||
// Module: PriorityNotificationQueue
|
// Module: PriorityNotificationQueue
|
||||||
//
|
//
|
||||||
// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person or organization
|
// Permission is hereby granted, free of charge, to any person or organization
|
||||||
// obtaining a copy of the software and accompanying documentation covered by
|
// obtaining a copy of the software and accompanying documentation covered by
|
||||||
// this license (the "Software") to use, reproduce, display, distribute,
|
// this license (the "Software") to use, reproduce, display, distribute,
|
||||||
// execute, and transmit the Software, and to prepare derivative works of the
|
// 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
|
// Software, and to permit third-parties to whom the Software is furnished to
|
||||||
// do so, all subject to the following:
|
// do so, all subject to the following:
|
||||||
//
|
//
|
||||||
// The copyright notices in the Software and this entire statement, including
|
// The copyright notices in the Software and this entire statement, including
|
||||||
// the above license grant, this restriction and the following disclaimer,
|
// 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
|
// 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
|
// all derivative works of the Software, unless such copies or derivative
|
||||||
// works are solely in the form of machine-executable object code generated by
|
// works are solely in the form of machine-executable object code generated by
|
||||||
// a source language processor.
|
// a source language processor.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
// 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
|
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/PriorityNotificationQueue.h"
|
#include "Poco/PriorityNotificationQueue.h"
|
||||||
#include "Poco/NotificationCenter.h"
|
#include "Poco/NotificationCenter.h"
|
||||||
#include "Poco/Notification.h"
|
#include "Poco/Notification.h"
|
||||||
#include "Poco/SingletonHolder.h"
|
#include "Poco/SingletonHolder.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
PriorityNotificationQueue::PriorityNotificationQueue()
|
PriorityNotificationQueue::PriorityNotificationQueue()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PriorityNotificationQueue::~PriorityNotificationQueue()
|
PriorityNotificationQueue::~PriorityNotificationQueue()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PriorityNotificationQueue::enqueueNotification(Notification::Ptr pNotification, int priority)
|
void PriorityNotificationQueue::enqueueNotification(Notification::Ptr pNotification, int priority)
|
||||||
{
|
{
|
||||||
poco_check_ptr (pNotification);
|
poco_check_ptr (pNotification);
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
if (_waitQueue.empty())
|
if (_waitQueue.empty())
|
||||||
{
|
{
|
||||||
_nfQueue.insert(NfQueue::value_type(priority, pNotification));
|
_nfQueue.insert(NfQueue::value_type(priority, pNotification));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
poco_assert_dbg(_nfQueue.empty());
|
poco_assert_dbg(_nfQueue.empty());
|
||||||
WaitInfo* pWI = _waitQueue.front();
|
WaitInfo* pWI = _waitQueue.front();
|
||||||
_waitQueue.pop_front();
|
_waitQueue.pop_front();
|
||||||
pWI->pNf = pNotification;
|
pWI->pNf = pNotification;
|
||||||
pWI->nfAvailable.set();
|
pWI->nfAvailable.set();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Notification* PriorityNotificationQueue::dequeueNotification()
|
Notification* PriorityNotificationQueue::dequeueNotification()
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
return dequeueOne().duplicate();
|
return dequeueOne().duplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Notification* PriorityNotificationQueue::waitDequeueNotification()
|
Notification* PriorityNotificationQueue::waitDequeueNotification()
|
||||||
{
|
{
|
||||||
Notification::Ptr pNf;
|
Notification::Ptr pNf;
|
||||||
WaitInfo* pWI = 0;
|
WaitInfo* pWI = 0;
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
pNf = dequeueOne();
|
pNf = dequeueOne();
|
||||||
if (pNf) return pNf.duplicate();
|
if (pNf) return pNf.duplicate();
|
||||||
pWI = new WaitInfo;
|
pWI = new WaitInfo;
|
||||||
_waitQueue.push_back(pWI);
|
_waitQueue.push_back(pWI);
|
||||||
}
|
}
|
||||||
pWI->nfAvailable.wait();
|
pWI->nfAvailable.wait();
|
||||||
pNf = pWI->pNf;
|
pNf = pWI->pNf;
|
||||||
delete pWI;
|
delete pWI;
|
||||||
return pNf.duplicate();
|
return pNf.duplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Notification* PriorityNotificationQueue::waitDequeueNotification(long milliseconds)
|
Notification* PriorityNotificationQueue::waitDequeueNotification(long milliseconds)
|
||||||
{
|
{
|
||||||
Notification::Ptr pNf;
|
Notification::Ptr pNf;
|
||||||
WaitInfo* pWI = 0;
|
WaitInfo* pWI = 0;
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
pNf = dequeueOne();
|
pNf = dequeueOne();
|
||||||
if (pNf) return pNf.duplicate();
|
if (pNf) return pNf.duplicate();
|
||||||
pWI = new WaitInfo;
|
pWI = new WaitInfo;
|
||||||
_waitQueue.push_back(pWI);
|
_waitQueue.push_back(pWI);
|
||||||
}
|
}
|
||||||
if (pWI->nfAvailable.tryWait(milliseconds))
|
if (pWI->nfAvailable.tryWait(milliseconds))
|
||||||
{
|
{
|
||||||
pNf = pWI->pNf;
|
pNf = pWI->pNf;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
pNf = pWI->pNf;
|
pNf = pWI->pNf;
|
||||||
for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
|
for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
|
||||||
{
|
{
|
||||||
if (*it == pWI)
|
if (*it == pWI)
|
||||||
{
|
{
|
||||||
_waitQueue.erase(it);
|
_waitQueue.erase(it);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete pWI;
|
delete pWI;
|
||||||
return pNf.duplicate();
|
return pNf.duplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PriorityNotificationQueue::dispatch(NotificationCenter& notificationCenter)
|
void PriorityNotificationQueue::dispatch(NotificationCenter& notificationCenter)
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
Notification::Ptr pNf = dequeueOne();
|
Notification::Ptr pNf = dequeueOne();
|
||||||
while (pNf)
|
while (pNf)
|
||||||
{
|
{
|
||||||
notificationCenter.postNotification(pNf);
|
notificationCenter.postNotification(pNf);
|
||||||
pNf = dequeueOne();
|
pNf = dequeueOne();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PriorityNotificationQueue::wakeUpAll()
|
void PriorityNotificationQueue::wakeUpAll()
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
|
for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
|
||||||
{
|
{
|
||||||
(*it)->nfAvailable.set();
|
(*it)->nfAvailable.set();
|
||||||
}
|
}
|
||||||
_waitQueue.clear();
|
_waitQueue.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PriorityNotificationQueue::empty() const
|
bool PriorityNotificationQueue::empty() const
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
return _nfQueue.empty();
|
return _nfQueue.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PriorityNotificationQueue::size() const
|
int PriorityNotificationQueue::size() const
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
return static_cast<int>(_nfQueue.size());
|
return static_cast<int>(_nfQueue.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PriorityNotificationQueue::clear()
|
void PriorityNotificationQueue::clear()
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
_nfQueue.clear();
|
_nfQueue.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PriorityNotificationQueue::hasIdleThreads() const
|
bool PriorityNotificationQueue::hasIdleThreads() const
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
return !_waitQueue.empty();
|
return !_waitQueue.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Notification::Ptr PriorityNotificationQueue::dequeueOne()
|
Notification::Ptr PriorityNotificationQueue::dequeueOne()
|
||||||
{
|
{
|
||||||
Notification::Ptr pNf;
|
Notification::Ptr pNf;
|
||||||
NfQueue::iterator it = _nfQueue.begin();
|
NfQueue::iterator it = _nfQueue.begin();
|
||||||
if (it != _nfQueue.end())
|
if (it != _nfQueue.end())
|
||||||
{
|
{
|
||||||
pNf = it->second;
|
pNf = it->second;
|
||||||
_nfQueue.erase(it);
|
_nfQueue.erase(it);
|
||||||
}
|
}
|
||||||
return pNf;
|
return pNf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PriorityNotificationQueue& PriorityNotificationQueue::defaultQueue()
|
namespace
|
||||||
{
|
{
|
||||||
static SingletonHolder<PriorityNotificationQueue> sh;
|
static SingletonHolder<PriorityNotificationQueue> sh;
|
||||||
return *sh.get();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
PriorityNotificationQueue& PriorityNotificationQueue::defaultQueue()
|
||||||
} // namespace Poco
|
{
|
||||||
|
return *sh.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Poco
|
||||||
|
@ -43,6 +43,8 @@
|
|||||||
#else
|
#else
|
||||||
#include "RWLock_WIN32.cpp"
|
#include "RWLock_WIN32.cpp"
|
||||||
#endif
|
#endif
|
||||||
|
#elif defined(POCO_ANDROID)
|
||||||
|
#include "RWLock_Android.cpp"
|
||||||
#elif defined(POCO_VXWORKS)
|
#elif defined(POCO_VXWORKS)
|
||||||
#include "RWLock_VX.cpp"
|
#include "RWLock_VX.cpp"
|
||||||
#else
|
#else
|
||||||
|
@ -61,7 +61,10 @@ void SharedLibraryImpl::loadImpl(const std::string& path)
|
|||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
if (_handle) throw LibraryAlreadyLoadedException(_path);
|
if (_handle) throw LibraryAlreadyLoadedException(_path);
|
||||||
_handle = LoadLibraryA(path.c_str());
|
DWORD flags(0);
|
||||||
|
Path p(path);
|
||||||
|
if (p.isAbsolute()) flags |= LOAD_WITH_ALTERED_SEARCH_PATH;
|
||||||
|
_handle = LoadLibraryExA(path.c_str(), 0, flags);
|
||||||
if (!_handle) throw LibraryLoadException(path);
|
if (!_handle) throw LibraryLoadException(path);
|
||||||
_path = path;
|
_path = path;
|
||||||
}
|
}
|
||||||
|
@ -55,11 +55,11 @@ int Timezone::utcOffset()
|
|||||||
|
|
||||||
int Timezone::dst()
|
int Timezone::dst()
|
||||||
{
|
{
|
||||||
std::time_t now = std::time(NULL);
|
std::time_t now = std::time(NULL);
|
||||||
struct std::tm t;
|
struct std::tm t;
|
||||||
if (!localtime_r(&now, &t))
|
if (localtime_r(&now, &t) != OK)
|
||||||
throw Poco::SystemException("cannot get local time DST offset");
|
throw Poco::SystemException("cannot get local time DST offset");
|
||||||
return t.tm_isdst == 1 ? 3600 : 0;
|
return t.tm_isdst == 1 ? 3600 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user