Peroperly use the maxThreads specified in a TCPServerParameters to have the TCPServerDispatcher create a Threadpool with the correct capacity.

This commit is contained in:
karlr42
2014-03-06 19:44:54 +00:00
parent 715a09ff47
commit b509b7e91a
6 changed files with 43 additions and 2 deletions

View File

@@ -175,6 +175,7 @@ void TCPServerTest::testMultiConnections()
srv.start();
assert (srv.currentConnections() == 0);
assert (srv.currentThreads() == 0);
assert (srv.maxThreads() >= 4);
assert (srv.queuedConnections() == 0);
assert (srv.totalConnections() == 0);
@@ -252,6 +253,16 @@ void TCPServerTest::testMultiConnections()
assert (srv.currentConnections() == 0);
}
void TCPServerTest::testThreadCapacity(){
ServerSocket svs(0);
TCPServerParams* pParams = new TCPServerParams;
pParams->setMaxThreads(64);
TCPServer srv(new TCPServerConnectionFactoryImpl<EchoConnection>(), svs, pParams);
srv.start();
assert (srv.maxThreads() >= 64);
}
void TCPServerTest::setUp()
{
@@ -270,6 +281,7 @@ CppUnit::Test* TCPServerTest::suite()
CppUnit_addTest(pSuite, TCPServerTest, testOneConnection);
CppUnit_addTest(pSuite, TCPServerTest, testTwoConnections);
CppUnit_addTest(pSuite, TCPServerTest, testMultiConnections);
CppUnit_addTest(pSuite, TCPServerTest, testThreadCapacity);
return pSuite;
}

View File

@@ -49,6 +49,7 @@ public:
void testOneConnection();
void testTwoConnections();
void testMultiConnections();
void testThreadCapacity();
void setUp();
void tearDown();