FreeRDP/winpr/libwinpr/pool/test/TestPoolWork.c

38 lines
833 B
C
Raw Normal View History

2013-01-21 06:15:55 +04:00
#include <winpr/crt.h>
#include <winpr/pool.h>
static int count = 0;
2013-01-21 06:15:55 +04:00
void test_WorkCallback(PTP_CALLBACK_INSTANCE instance, void* context, PTP_WORK work)
{
printf("Hello %s: %d\n", context, count++);
2013-01-21 06:15:55 +04:00
}
int TestPoolWork(int argc, char* argv[])
{
int index;
2013-01-21 06:15:55 +04:00
TP_WORK * work;
work = CreateThreadpoolWork((PTP_WORK_CALLBACK) test_WorkCallback, "world", NULL);
2013-01-21 06:15:55 +04:00
if (!work)
{
printf("CreateThreadpoolWork failure\n");
return -1;
}
/**
* You can post a work object one or more times (up to MAXULONG) without waiting for prior callbacks to complete.
* The callbacks will execute in parallel. To improve efficiency, the thread pool may throttle the threads.
*/
for (index = 0; index < 10; index++)
SubmitThreadpoolWork(work);
2013-01-21 06:15:55 +04:00
WaitForThreadpoolWorkCallbacks(work, FALSE);
CloseThreadpoolWork(work);
return 0;
}