Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,30 @@ class IgniteClientTestSuiteFixture

BOOST_CHECK_EQUAL(GetActiveConnections(), expect);
}
/**
* Get the number of threads once it stops changing: a joined thread is still listed in the process for a while.
*
* @return Number of threads.
*/
static int32_t GetSettledThreadsCount()
{
int32_t cnt = ignite::common::concurrent::GetThreadsCount();

for (int i = 0; i < 25; ++i)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(200));

int32_t cnt0 = ignite::common::concurrent::GetThreadsCount();

if (cnt0 == cnt)
break;

cnt = cnt0;
}

return cnt;
}

/**
* Check that client started with specified size of user thread pool started exactly the specified number of threads
* in thread pool.
Expand All @@ -85,7 +109,7 @@ class IgniteClientTestSuiteFixture
server.PushHandshakeResponse(true);
server.Start();

int32_t threadsBefore = ignite::common::concurrent::GetThreadsCount();
int32_t threadsBefore = GetSettledThreadsCount();
int32_t netThreads = 1;

#ifdef _WIN32
Expand All @@ -103,7 +127,7 @@ class IgniteClientTestSuiteFixture
BOOST_CHECK_EQUAL(threadsExpected, threadsActual);
}

int32_t threadsAfter = ignite::common::concurrent::GetThreadsCount();
int32_t threadsAfter = GetSettledThreadsCount();

BOOST_CHECK_EQUAL(threadsBefore, threadsAfter);
BOOST_CHECK_EQUAL(num, cfg.GetUserThreadPoolSize());
Expand Down
Loading