mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-06 08:41:11 +01:00
- return bool from Thread::trySleep()
- updated documentiation - amended tests - updated CHANGELOG
This commit is contained in:
parent
0d58de8bc8
commit
63850e8778
19
CHANGELOG
19
CHANGELOG
@ -33,10 +33,27 @@ Release 1.5.3 (2014-05-xx)
|
|||||||
- fixed GH #380: SecureSocket+DialogSocket crashes with SIGSEGV when timeout occours
|
- fixed GH #380: SecureSocket+DialogSocket crashes with SIGSEGV when timeout occours
|
||||||
- Improve RSADigestEngine, using Poco::Crypto::DigestEngine to calculate hash before signing
|
- Improve RSADigestEngine, using Poco::Crypto::DigestEngine to calculate hash before signing
|
||||||
- added Poco::PBKDF2Engine
|
- added Poco::PBKDF2Engine
|
||||||
|
- Fixed GH #380: SecureSocket+DialogSocket crashes with SIGSEGV when timeout occours
|
||||||
- added support for a 'Priority' attribute on cookies.
|
- added support for a 'Priority' attribute on cookies.
|
||||||
- GH #386: fixed bug in MailMessage without content-transfer-encoding header
|
- GH #386: fixed bug in MailMessage without content-transfer-encoding header
|
||||||
- GH #384: ew hash algorithms support for RSADigestEngine
|
- GH #384: ew hash algorithms support for RSADigestEngine
|
||||||
|
- fixed Clock overflow bug on Windows
|
||||||
|
- Poco::ByteOrder now uses intrinsics, if available
|
||||||
|
- CMake: added /bigobj option for msvc
|
||||||
|
- Fix typo to restore Net/TestSuite_x64_vs120 build
|
||||||
|
- correct path for CONFIGURE_FILE in CMakeLists.txt
|
||||||
|
- Building Poco 1.5.2 for Synology RS812+ (Intel Atom) (honor POCO_NO_INOTIFY)
|
||||||
|
- added WEC2013 support to buildwin.cmd and buildwin.ps1
|
||||||
|
- HTMLForm: in URL encoding, percent-encode more characters
|
||||||
|
- Fixed #include <linux/if.h> conflict with other libraries
|
||||||
|
- Poco::Net::X509Certificate::verify() no longer uses DNS reverse lookups to validate host names
|
||||||
|
- cert hostname validation is case insensitive and stricter for wildcard certificates
|
||||||
|
- TCPServer: do not reduce the capacity of the default ThreadPool
|
||||||
|
- added POCO_LOG_DEBUG flag
|
||||||
|
- Zip: fixed a crash caused by an I/O error
|
||||||
|
- added runtest script for windows
|
||||||
|
- added SQlite Full Text Search support
|
||||||
|
- added Thread::trySleep() and Thread::wakeUp()
|
||||||
|
|
||||||
Release 1.5.2 (2013-09-16)
|
Release 1.5.2 (2013-09-16)
|
||||||
==========================
|
==========================
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void sleep(long milliseconds);
|
void sleep(long milliseconds);
|
||||||
|
|
||||||
void trySleep(long milliseconds);
|
bool trySleep(long milliseconds);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -187,16 +187,27 @@ public:
|
|||||||
bool isRunning() const;
|
bool isRunning() const;
|
||||||
/// Returns true if the thread is running.
|
/// Returns true if the thread is running.
|
||||||
|
|
||||||
void trySleep(long milliseconds);
|
bool trySleep(long milliseconds);
|
||||||
/// Starts an interruptible sleep. Thread will remain suspended
|
/// Starts an interruptible sleep. When trySleep() is called,
|
||||||
/// until (a) the timeout expires or (b) wakeUp() is called.
|
/// the thread will remain suspended until:
|
||||||
/// The trySleep()/wakeUp() pair of functions should be used with
|
/// - the timeout expires or
|
||||||
/// understanding that this suspended state is not a true sleep,
|
/// - wakeUp() is called
|
||||||
|
///
|
||||||
|
/// Function returns true if sleep attempt was completed, false
|
||||||
|
/// if sleep was interrupted by a wakeUp() call.
|
||||||
|
/// A frequent scenario where trySleep()/wakeUp() pair of functions
|
||||||
|
/// is useful is with threads spending most of the time idle,
|
||||||
|
/// with periodic activity between the idle times; trying to sleep
|
||||||
|
/// (as opposed to sleeping) allows immediate ending of idle thread
|
||||||
|
/// from the outside.
|
||||||
|
///
|
||||||
|
/// The trySleep() and wakeUp() calls should be used with
|
||||||
|
/// understanding that the suspended state is not a true sleep,
|
||||||
/// but rather a state of waiting for an event, with timeout
|
/// but rather a state of waiting for an event, with timeout
|
||||||
/// expiration. This in essence means that calling wakeUp()
|
/// expiration. This makes order of calls significantant; calling
|
||||||
/// before calling trySleep() will prevent the next trySleep()
|
/// wakeUp() before calling trySleep() will prevent the next
|
||||||
/// call to actually suspend the thread (which, in some scenarios,
|
/// trySleep() call to actually suspend the thread (which, in
|
||||||
/// may be desirable behavior).
|
/// some scenarios, may be desirable behavior).
|
||||||
|
|
||||||
void wakeUp();
|
void wakeUp();
|
||||||
/// Wakes up the thread which is in the state of interruptible
|
/// Wakes up the thread which is in the state of interruptible
|
||||||
|
@ -57,9 +57,9 @@ void Runnable::sleep(long milliseconds)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Runnable::trySleep(long milliseconds)
|
bool Runnable::trySleep(long milliseconds)
|
||||||
{
|
{
|
||||||
Thread::current()->trySleep(milliseconds);
|
return Thread::current()->trySleep(milliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,18 +60,18 @@ namespace Poco {
|
|||||||
Thread::Thread():
|
Thread::Thread():
|
||||||
_id(uniqueId()),
|
_id(uniqueId()),
|
||||||
_name(makeName()),
|
_name(makeName()),
|
||||||
_pTLS(0)
|
_pTLS(0),
|
||||||
|
_event(true)
|
||||||
{
|
{
|
||||||
_event.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Thread::Thread(const std::string& name):
|
Thread::Thread(const std::string& name):
|
||||||
_id(uniqueId()),
|
_id(uniqueId()),
|
||||||
_name(name),
|
_name(name),
|
||||||
_pTLS(0)
|
_pTLS(0),
|
||||||
|
_event(true)
|
||||||
{
|
{
|
||||||
_event.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -124,10 +124,9 @@ bool Thread::tryJoin(long milliseconds)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Thread::trySleep(long milliseconds)
|
bool Thread::trySleep(long milliseconds)
|
||||||
{
|
{
|
||||||
_event.tryWait(milliseconds);
|
return !_event.tryWait(milliseconds);
|
||||||
_event.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::wakeUp()
|
void Thread::wakeUp()
|
||||||
|
@ -137,17 +137,17 @@ private:
|
|||||||
class TrySleepRunnable : public Runnable
|
class TrySleepRunnable : public Runnable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TrySleepRunnable() : _counter(0)
|
TrySleepRunnable() : _counter(0), _sleepy(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
trySleep(300000);
|
_sleepy = !trySleep(300000);
|
||||||
++_counter;
|
++_counter;
|
||||||
trySleep(300000);
|
_sleepy = !trySleep(300000);
|
||||||
++_counter;
|
++_counter;
|
||||||
trySleep(10);
|
_sleepy = !trySleep(10);
|
||||||
++_counter;
|
++_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,8 +156,14 @@ public:
|
|||||||
return _counter;
|
return _counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isSleepy() const
|
||||||
|
{
|
||||||
|
return _sleepy;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _counter;
|
int _counter;
|
||||||
|
bool _sleepy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -295,23 +301,27 @@ void ThreadTest::testTrySleep()
|
|||||||
{
|
{
|
||||||
Thread thread;
|
Thread thread;
|
||||||
TrySleepRunnable r;
|
TrySleepRunnable r;
|
||||||
|
assert(r.isSleepy());
|
||||||
assert(!thread.isRunning());
|
assert(!thread.isRunning());
|
||||||
assert(r.counter() == 0);
|
assert(r.counter() == 0);
|
||||||
thread.start(r);
|
thread.start(r);
|
||||||
assert(thread.isRunning());
|
assert(thread.isRunning());
|
||||||
assert(r.counter() == 0);
|
assert(r.counter() == 0);
|
||||||
|
assert(r.isSleepy());
|
||||||
Thread::sleep(100);
|
Thread::sleep(100);
|
||||||
assert(r.counter() == 0);
|
assert(r.counter() == 0);
|
||||||
thread.wakeUp();
|
assert(r.isSleepy());
|
||||||
Thread::sleep(10);
|
thread.wakeUp(); Thread::sleep(10);
|
||||||
assert(r.counter() == 1);
|
assert(r.counter() == 1);
|
||||||
|
assert(r.isSleepy());
|
||||||
Thread::sleep(100);
|
Thread::sleep(100);
|
||||||
assert(r.counter() == 1);
|
assert(r.counter() == 1);
|
||||||
thread.wakeUp();
|
thread.wakeUp(); Thread::sleep(10);
|
||||||
Thread::sleep(10);
|
|
||||||
assert(r.counter() == 2);
|
assert(r.counter() == 2);
|
||||||
|
assert(r.isSleepy());
|
||||||
Thread::sleep(100);
|
Thread::sleep(100);
|
||||||
assert(r.counter() == 3);
|
assert(r.counter() == 3);
|
||||||
|
assert(!r.isSleepy());
|
||||||
assert(!thread.isRunning());
|
assert(!thread.isRunning());
|
||||||
thread.wakeUp();
|
thread.wakeUp();
|
||||||
assert(!thread.isRunning());
|
assert(!thread.isRunning());
|
||||||
|
Loading…
Reference in New Issue
Block a user