msvcp140_atomic_wait: Implement __std_bulk_submit_threadpool_work.

Signed-off-by: Daniel Lehman <dlehman@esri.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Daniel Lehman 2022-01-28 16:19:20 +01:00 committed by Alexandre Julliard
parent 69debac786
commit a7f71dbb7b
3 changed files with 28 additions and 1 deletions

View File

@ -31,6 +31,13 @@ unsigned int __stdcall __std_parallel_algorithms_hw_threads(void)
return _Thrd_hardware_concurrency();
}
void __stdcall __std_bulk_submit_threadpool_work(PTP_WORK work, size_t count)
{
TRACE("(%p %Iu)\n", work, count);
while (count--)
SubmitThreadpoolWork(work);
}
void __stdcall __std_close_threadpool_work(PTP_WORK work)
{
TRACE("(%p)\n", work);

View File

@ -11,7 +11,7 @@
@ stub __std_atomic_wait_get_deadline
@ stub __std_atomic_wait_get_remaining_timeout
@ stub __std_atomic_wait_indirect
@ stub __std_bulk_submit_threadpool_work
@ stdcall __std_bulk_submit_threadpool_work(ptr long)
@ stub __std_calloc_crt
@ stdcall __std_close_threadpool_work(ptr)
@ stdcall __std_create_threadpool_work(ptr ptr ptr)

View File

@ -24,6 +24,7 @@
static unsigned int (__stdcall *p___std_parallel_algorithms_hw_threads)(void);
static void (__stdcall *p___std_bulk_submit_threadpool_work)(PTP_WORK, size_t);
static void (__stdcall *p___std_close_threadpool_work)(PTP_WORK);
static PTP_WORK (__stdcall *p___std_create_threadpool_work)(PTP_WORK_CALLBACK, void*, PTP_CALLBACK_ENVIRON);
static void (__stdcall *p___std_submit_threadpool_work)(PTP_WORK);
@ -40,6 +41,7 @@ static HMODULE init(void)
SET(p___std_parallel_algorithms_hw_threads, "__std_parallel_algorithms_hw_threads");
SET(p___std_bulk_submit_threadpool_work, "__std_bulk_submit_threadpool_work");
SET(p___std_close_threadpool_work, "__std_close_threadpool_work");
SET(p___std_create_threadpool_work, "__std_create_threadpool_work");
SET(p___std_submit_threadpool_work, "__std_submit_threadpool_work");
@ -86,6 +88,7 @@ static void test_threadpool_work(void)
if (0) /* crash on windows */
{
p___std_bulk_submit_threadpool_work(NULL, 5);
p___std_create_threadpool_work(NULL, NULL, NULL);
p___std_submit_threadpool_work(NULL);
p___std_wait_for_threadpool_work_callbacks(NULL, FALSE);
@ -103,6 +106,23 @@ static void test_threadpool_work(void)
ok(cb_work == work, "expected %p, got %p\n", work, cb_work);
ok(cb_context == &workcalled, "expected %p, got %p\n", &workcalled, cb_context);
/* bulk submit */
workcalled = 0;
work = p___std_create_threadpool_work(threadpool_workcallback, &workcalled, NULL);
ok(!!work, "failed to create threadpool_work\n");
p___std_bulk_submit_threadpool_work(work, 13);
p___std_wait_for_threadpool_work_callbacks(work, FALSE);
p___std_close_threadpool_work(work);
ok(workcalled == 13, "expected work to be called 13 times, got %d\n", workcalled);
workcalled = 0;
work = p___std_create_threadpool_work(threadpool_workcallback, &workcalled, NULL);
ok(!!work, "failed to create threadpool_work\n");
p___std_bulk_submit_threadpool_work(work, 0);
p___std_wait_for_threadpool_work_callbacks(work, FALSE);
p___std_close_threadpool_work(work);
ok(workcalled == 0, "expected no work, got %d\n", workcalled);
/* test with environment */
cb_event = CreateEventW(NULL, TRUE, FALSE, NULL);
memset(&environment, 0, sizeof(environment));