msvcrt: Improve CurrentScheduler::Get implementation.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2017-04-03 15:05:49 +02:00 committed by Alexandre Julliard
parent 2d4be5cb35
commit 6ad1e9a954
1 changed files with 12 additions and 15 deletions

View File

@ -196,6 +196,17 @@ static Scheduler* try_get_current_scheduler(void)
return context->scheduler.scheduler; return context->scheduler.scheduler;
} }
static Scheduler* get_current_scheduler(void)
{
ExternalContextBase *context = (ExternalContextBase*)get_current_context();
if (context->context.vtable != &MSVCRT_ExternalContextBase_vtable) {
ERR("unknown context set\n");
return NULL;
}
return context->scheduler.scheduler;
}
/* ?CurrentContext@Context@Concurrency@@SAPAV12@XZ */ /* ?CurrentContext@Context@Concurrency@@SAPAV12@XZ */
/* ?CurrentContext@Context@Concurrency@@SAPEAV12@XZ */ /* ?CurrentContext@Context@Concurrency@@SAPEAV12@XZ */
Context* __cdecl Context_CurrentContext(void) Context* __cdecl Context_CurrentContext(void)
@ -867,22 +878,8 @@ static void create_default_scheduler(void)
/* ?Get@CurrentScheduler@Concurrency@@SAPEAVScheduler@2@XZ */ /* ?Get@CurrentScheduler@Concurrency@@SAPEAVScheduler@2@XZ */
Scheduler* __cdecl CurrentScheduler_Get(void) Scheduler* __cdecl CurrentScheduler_Get(void)
{ {
ExternalContextBase *context = (ExternalContextBase*)get_current_context();
TRACE("()\n"); TRACE("()\n");
return get_current_scheduler();
if(context->context.vtable != &MSVCRT_ExternalContextBase_vtable) {
ERR("unknown context set\n");
return NULL;
}
if(context->scheduler.scheduler)
return context->scheduler.scheduler;
create_default_scheduler();
context->scheduler.scheduler = &default_scheduler->scheduler;
call_Scheduler_Reference(&default_scheduler->scheduler);
return &default_scheduler->scheduler;
} }
/* ?CreateScheduleGroup@CurrentScheduler@Concurrency@@SAPAVScheduleGroup@2@AAVlocation@2@@Z */ /* ?CreateScheduleGroup@CurrentScheduler@Concurrency@@SAPAVScheduleGroup@2@AAVlocation@2@@Z */