Module: wine Branch: oldstable Commit: cbc58a50275adae69adb4d31a8e187abbac75c74 URL: https://gitlab.winehq.org/wine/wine/-/commit/cbc58a50275adae69adb4d31a8e187a... Author: Torge Matthies <tmatthies(a)codeweavers.com> Date: Wed Aug 17 15:19:10 2022 +0200 msvcr100: Factor out the mapping of a context to a scheduler. Signed-off-by: Torge Matthies <tmatthies(a)codeweavers.com> (cherry picked from commit e704c445429391ab2d0874ff6cfe8f708a69f8fd) Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> --- dlls/msvcrt/concurrency.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/dlls/msvcrt/concurrency.c b/dlls/msvcrt/concurrency.c index 83ecdab89ff..719ceec8fb8 100644 --- a/dlls/msvcrt/concurrency.c +++ b/dlls/msvcrt/concurrency.c @@ -694,29 +694,38 @@ static Context* get_current_context(void) return ret; } +static Scheduler* get_scheduler_from_context(Context *ctx) +{ + ExternalContextBase *context = (ExternalContextBase*)ctx; + + if (context->context.vtable != &ExternalContextBase_vtable) + return NULL; + return context->scheduler.scheduler; +} + static Scheduler* try_get_current_scheduler(void) { - ExternalContextBase *context = (ExternalContextBase*)try_get_current_context(); + Context *context = try_get_current_context(); + Scheduler *ret; if (!context) return NULL; - if (context->context.vtable != &ExternalContextBase_vtable) { + ret = get_scheduler_from_context(context); + if (!ret) ERR("unknown context set\n"); - return NULL; - } - return context->scheduler.scheduler; + return ret; } static Scheduler* get_current_scheduler(void) { - ExternalContextBase *context = (ExternalContextBase*)get_current_context(); + Context *context = get_current_context(); + Scheduler *ret; - if (context->context.vtable != &ExternalContextBase_vtable) { + ret = get_scheduler_from_context(context); + if (!ret) ERR("unknown context set\n"); - return NULL; - } - return context->scheduler.scheduler; + return ret; } /* ?CurrentContext(a)Context@Concurrency@@SAPAV12(a)XZ */