mirror of
https://github.com/pocoproject/poco.git
synced 2025-11-08 06:42:55 +01:00
Fix/posix sleep (#3705)
* fix(Thread_POSIX): sleep() poor performance #3703 * chore(vscode): add file associations * fix(TaskManager): waits for all threads in the ThreadPool #3704 * fix(Thread): call std::this_thread::sleep_for() to sleep #3703 * fix(PollSet): wakeup fd is never read #3708 * feat(Thread): Add Thread::set/getAffinity() #3709 * doc(Thread): Thread::trySleep() assertion #3710 * fix(PollSet): wakeup fd is never read (windows portion and some other optimizations) #3708 * feat(SocketReactor): improvements #3713 * chore(ThreadTest): add missing include * fix(PollSet): wakeup fd is never read #3708 * fix(Any): #3682 #3683 #3692 #3712 * fix(mingw): lowercase winsock2 and iphlpapi to allow cross compile #3711 * feat(Thread): Add Thread::set/getAffinity() #3709 * chore(SocketReactor): one-liners inlined, removed redundant try/catch in dospatch, remove unused onBusy() * feat(SocketReactor): add socket to ErrorNotification * fix(SocketReactor): pollTimeout assignment and ConnectorTest leak
This commit is contained in:
committed by
GitHub
parent
d1b398ddc6
commit
86a4f0045e
@@ -20,6 +20,7 @@
|
||||
#include "Poco/Net/ServerSocket.h"
|
||||
#include "Poco/Net/SocketAddress.h"
|
||||
#include "Poco/Observer.h"
|
||||
#include "Poco/Stopwatch.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/Thread.h"
|
||||
#include <sstream>
|
||||
@@ -39,6 +40,7 @@ using Poco::Net::TimeoutNotification;
|
||||
using Poco::Net::ErrorNotification;
|
||||
using Poco::Net::ShutdownNotification;
|
||||
using Poco::Observer;
|
||||
using Poco::Stopwatch;
|
||||
using Poco::IllegalStateException;
|
||||
using Poco::Thread;
|
||||
|
||||
@@ -135,12 +137,18 @@ namespace
|
||||
checkReadableObserverCount(1);
|
||||
_reactor.removeEventHandler(_socket, Observer<ClientServiceHandler, ReadableNotification>(*this, &ClientServiceHandler::onReadable));
|
||||
checkReadableObserverCount(0);
|
||||
if (_once || _data.size() == MAX_DATA_SIZE)
|
||||
if (_once)
|
||||
{
|
||||
_reactor.stop();
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (_data.size() == MAX_DATA_SIZE)
|
||||
{
|
||||
_reactor.stop();
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
void onWritable(WritableNotification* pNf)
|
||||
@@ -260,7 +268,6 @@ namespace
|
||||
static bool _once;
|
||||
};
|
||||
|
||||
|
||||
std::string ClientServiceHandler::_data;
|
||||
bool ClientServiceHandler::_readableError = false;
|
||||
bool ClientServiceHandler::_writableError = false;
|
||||
@@ -599,6 +606,23 @@ void SocketReactorTest::testSocketConnectorDeadlock()
|
||||
}
|
||||
|
||||
|
||||
void SocketReactorTest::testSocketReactorWakeup()
|
||||
{
|
||||
SocketReactor::Params params;
|
||||
params.pollTimeout = 1000000000;
|
||||
params.sleepLimit = 1000000000;
|
||||
SocketReactor reactor(params);
|
||||
Thread thread;
|
||||
Stopwatch sw;
|
||||
sw.start();
|
||||
thread.start(reactor);
|
||||
reactor.stop();
|
||||
thread.join();
|
||||
sw.stop();
|
||||
assertTrue (sw.elapsed() < 100000);
|
||||
}
|
||||
|
||||
|
||||
void SocketReactorTest::setUp()
|
||||
{
|
||||
ClientServiceHandler::setCloseOnTimeout(false);
|
||||
@@ -621,6 +645,7 @@ CppUnit::Test* SocketReactorTest::suite()
|
||||
CppUnit_addTest(pSuite, SocketReactorTest, testSocketConnectorTimeout);
|
||||
CppUnit_addTest(pSuite, SocketReactorTest, testDataCollection);
|
||||
CppUnit_addTest(pSuite, SocketReactorTest, testSocketConnectorDeadlock);
|
||||
CppUnit_addTest(pSuite, SocketReactorTest, testSocketReactorWakeup);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user