From: Piotr Caban Subject: [PATCH] msvcr100: Improve ThreadScheduler_ScheduleTask_loc stub. Message-Id: Date: Sun, 3 Apr 2022 20:30:41 +0200 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45916 Signed-off-by: Piotr Caban --- dlls/msvcrt/concurrency.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/dlls/msvcrt/concurrency.c b/dlls/msvcrt/concurrency.c index 54b2c49db99..2ca6421b0e7 100644 --- a/dlls/msvcrt/concurrency.c +++ b/dlls/msvcrt/concurrency.c @@ -1220,11 +1220,45 @@ DEFINE_THISCALL_WRAPPER(ThreadScheduler_CreateScheduleGroup, 4) return NULL; } +typedef struct +{ + void (__cdecl *proc)(void*); + void *data; +} schedule_task_arg; + +static void WINAPI schedule_task_proc(PTP_CALLBACK_INSTANCE instance, void *context, PTP_WORK work) +{ + schedule_task_arg arg; + + arg = *(schedule_task_arg*)context; + operator_delete(context); + arg.proc(arg.data); +} + DEFINE_THISCALL_WRAPPER(ThreadScheduler_ScheduleTask_loc, 16) void __thiscall ThreadScheduler_ScheduleTask_loc(ThreadScheduler *this, void (__cdecl *proc)(void*), void* data, /*location*/void *placement) { + schedule_task_arg *arg; + TP_WORK *work; + FIXME("(%p %p %p %p) stub\n", this, proc, data, placement); + + arg = operator_new(sizeof(*arg)); + arg->proc = proc; + arg->data = data; + + work = CreateThreadpoolWork(schedule_task_proc, arg, NULL); + if(!work) { + scheduler_resource_allocation_error e; + + operator_delete(arg); + scheduler_resource_allocation_error_ctor_name(&e, NULL, + HRESULT_FROM_WIN32(GetLastError())); + _CxxThrowException(&e, &scheduler_resource_allocation_error_exception_type); + } + SubmitThreadpoolWork(work); + CloseThreadpoolWork(work); } DEFINE_THISCALL_WRAPPER(ThreadScheduler_ScheduleTask, 12) @@ -1232,6 +1266,7 @@ void __thiscall ThreadScheduler_ScheduleTask(ThreadScheduler *this, void (__cdecl *proc)(void*), void* data) { FIXME("(%p %p %p) stub\n", this, proc, data); + ThreadScheduler_ScheduleTask_loc(this, proc, data, NULL); } DEFINE_THISCALL_WRAPPER(ThreadScheduler_IsAvailableLocation, 8)