This commit is contained in:
andrey.bychkov
2024-09-17 12:31:03 +03:00
parent bc6b584480
commit b99c51181d

View File

@@ -154,6 +154,7 @@ TEST(ClientServer, DynamicClients) {
auto s = createServer<true, true, 10_KiB>(); auto s = createServer<true, true, 10_KiB>();
const auto spawnClient = [&clients, &clients_mutex]() { const auto spawnClient = [&clients, &clients_mutex]() {
if (clients.size() > 100) return;
auto c = new ClientSendThread(); auto c = new ClientSendThread();
c->startSend(); c->startSend();
clients_mutex.lock(); clients_mutex.lock();
@@ -173,16 +174,17 @@ TEST(ClientServer, DynamicClients) {
spawnThread.start( spawnThread.start(
[&spawnClient]() { [&spawnClient]() {
const int new_cnt = randomi() % 10; const int new_cnt = 7;
piForTimes(new_cnt) { piForTimes(new_cnt) {
spawnClient(); spawnClient();
} }
piCout << "+++++++";
}, },
12_Hz); 52_Hz);
deleteThread.start( deleteThread.start(
[&clients, &clients_mutex]() { [&clients, &clients_mutex]() {
const int rm_cnt = randomi() % 10; const int rm_cnt = 8;
piForTimes(rm_cnt) { piForTimes(rm_cnt) {
ClientSendThread * c = nullptr; ClientSendThread * c = nullptr;
clients_mutex.lock(); clients_mutex.lock();
@@ -195,8 +197,9 @@ TEST(ClientServer, DynamicClients) {
piCout << "remove client" << clients.size(); piCout << "remove client" << clients.size();
} }
} }
piCout << "----------";
}, },
13_Hz); 53_Hz);
(10_s).sleep(); (10_s).sleep();