Daniel Lehman : msvcp140_atomic_wait: Implement __std_bulk_submit_threadpool_work.
Alexandre Julliard
julliard at winehq.org
Fri Jan 28 14:29:33 CST 2022
Module: wine
Branch: master
Commit: a7f71dbb7b6146a95b5fe551a9e27ba3347a529c
URL: https://source.winehq.org/git/wine.git/?a=commit;h=a7f71dbb7b6146a95b5fe551a9e27ba3347a529c
Author: Daniel Lehman <dlehman at esri.com>
Date: Fri Jan 28 16:19:20 2022 +0100
msvcp140_atomic_wait: Implement __std_bulk_submit_threadpool_work.
Signed-off-by: Daniel Lehman <dlehman at esri.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcp140_atomic_wait/main.c | 7 +++++++
dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec | 2 +-
.../tests/msvcp140_atomic_wait.c | 20 ++++++++++++++++++++
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/dlls/msvcp140_atomic_wait/main.c b/dlls/msvcp140_atomic_wait/main.c
index c00ed08bffe..f489a7d8e05 100644
--- a/dlls/msvcp140_atomic_wait/main.c
+++ b/dlls/msvcp140_atomic_wait/main.c
@@ -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);
diff --git a/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec b/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec
index 5b03b7ccfe8..bb4edfb76e5 100644
--- a/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec
+++ b/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec
@@ -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)
diff --git a/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c b/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c
index f67270fe3b5..3a971bb4ce3 100644
--- a/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c
+++ b/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c
@@ -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));
More information about the wine-cvs
mailing list