FreeRDP/winpr/libwinpr/utils/test/TestStreamPool.c

79 lines
1.7 KiB
C
Raw Normal View History

#include <winpr/crt.h>
#include <winpr/stream.h>
#include <winpr/collections.h>
#define BUFFER_SIZE 16384
int TestStreamPool(int argc, char* argv[])
{
wStream* s[5] = { 0 };
char buffer[8192] = { 0 };
2021-07-29 11:18:52 +03:00
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
wStreamPool* pool = StreamPool_New(TRUE, BUFFER_SIZE);
2013-04-12 21:44:23 +04:00
s[0] = StreamPool_Take(pool, 0);
s[1] = StreamPool_Take(pool, 0);
s[2] = StreamPool_Take(pool, 0);
2020-05-12 15:57:39 +03:00
printf("%s\n", StreamPool_GetStatistics(pool, buffer, sizeof(buffer)));
Stream_Release(s[0]);
Stream_Release(s[1]);
Stream_Release(s[2]);
2020-05-12 15:57:39 +03:00
printf("%s\n", StreamPool_GetStatistics(pool, buffer, sizeof(buffer)));
2013-04-12 21:44:23 +04:00
s[3] = StreamPool_Take(pool, 0);
s[4] = StreamPool_Take(pool, 0);
2020-05-12 15:57:39 +03:00
printf("%s\n", StreamPool_GetStatistics(pool, buffer, sizeof(buffer)));
Stream_Release(s[3]);
Stream_Release(s[4]);
2020-05-12 15:57:39 +03:00
printf("%s\n", StreamPool_GetStatistics(pool, buffer, sizeof(buffer)));
2013-04-12 21:44:23 +04:00
s[2] = StreamPool_Take(pool, 0);
s[3] = StreamPool_Take(pool, 0);
s[4] = StreamPool_Take(pool, 0);
2020-05-12 15:57:39 +03:00
printf("%s\n", StreamPool_GetStatistics(pool, buffer, sizeof(buffer)));
Stream_AddRef(s[2]);
Stream_AddRef(s[3]);
Stream_AddRef(s[3]);
Stream_AddRef(s[4]);
Stream_AddRef(s[4]);
Stream_AddRef(s[4]);
Stream_Release(s[2]);
Stream_Release(s[2]);
Stream_Release(s[3]);
Stream_Release(s[3]);
Stream_Release(s[3]);
Stream_Release(s[4]);
Stream_Release(s[4]);
Stream_Release(s[4]);
Stream_Release(s[4]);
2020-05-12 15:57:39 +03:00
printf("%s\n", StreamPool_GetStatistics(pool, buffer, sizeof(buffer)));
2013-04-12 20:20:20 +04:00
2013-04-12 21:44:23 +04:00
s[2] = StreamPool_Take(pool, 0);
s[3] = StreamPool_Take(pool, 0);
s[4] = StreamPool_Take(pool, 0);
2013-04-12 20:20:20 +04:00
2020-05-12 15:57:39 +03:00
printf("%s\n", StreamPool_GetStatistics(pool, buffer, sizeof(buffer)));
2013-04-12 20:20:20 +04:00
StreamPool_Free(pool);
return 0;
}