Commit 5f72ec06 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Attach context to default scheduler on creation.

parent b2eab1a0
...@@ -267,6 +267,7 @@ typedef struct ...@@ -267,6 +267,7 @@ typedef struct
extern void *vtbl_wrapper_0; extern void *vtbl_wrapper_0;
extern void *vtbl_wrapper_4; extern void *vtbl_wrapper_4;
extern void *vtbl_wrapper_8; extern void *vtbl_wrapper_8;
extern void *vtbl_wrapper_16;
extern void *vtbl_wrapper_20; extern void *vtbl_wrapper_20;
extern void *vtbl_wrapper_28; extern void *vtbl_wrapper_28;
......
...@@ -49,6 +49,7 @@ static int scheduler_id = -1; ...@@ -49,6 +49,7 @@ static int scheduler_id = -1;
DEFINE_VTBL_WRAPPER(0); DEFINE_VTBL_WRAPPER(0);
DEFINE_VTBL_WRAPPER(4); DEFINE_VTBL_WRAPPER(4);
DEFINE_VTBL_WRAPPER(8); DEFINE_VTBL_WRAPPER(8);
DEFINE_VTBL_WRAPPER(16);
DEFINE_VTBL_WRAPPER(20); DEFINE_VTBL_WRAPPER(20);
DEFINE_VTBL_WRAPPER(28); DEFINE_VTBL_WRAPPER(28);
...@@ -114,6 +115,7 @@ static void ExternalContextBase_ctor(ExternalContextBase*); ...@@ -114,6 +115,7 @@ static void ExternalContextBase_ctor(ExternalContextBase*);
typedef struct Scheduler { typedef struct Scheduler {
const vtable_ptr *vtable; const vtable_ptr *vtable;
} Scheduler; } Scheduler;
#define call_Scheduler_Reference(this) CALL_VTBL_FUNC(this, 16, unsigned int, (Scheduler*), (this))
#define call_Scheduler_Release(this) CALL_VTBL_FUNC(this, 20, unsigned int, (Scheduler*), (this)) #define call_Scheduler_Release(this) CALL_VTBL_FUNC(this, 20, unsigned int, (Scheduler*), (this))
#define call_Scheduler_Attach(this) CALL_VTBL_FUNC(this, 28, void, (Scheduler*), (this)) #define call_Scheduler_Attach(this) CALL_VTBL_FUNC(this, 28, void, (Scheduler*), (this))
...@@ -143,6 +145,8 @@ static CRITICAL_SECTION default_scheduler_cs = { &default_scheduler_cs_debug, -1 ...@@ -143,6 +145,8 @@ static CRITICAL_SECTION default_scheduler_cs = { &default_scheduler_cs_debug, -1
static SchedulerPolicy default_scheduler_policy; static SchedulerPolicy default_scheduler_policy;
static ThreadScheduler *default_scheduler; static ThreadScheduler *default_scheduler;
static void create_default_scheduler(void);
static Context* try_get_current_context(void) static Context* try_get_current_context(void)
{ {
if (context_tls_index == TLS_OUT_OF_INDEXES) if (context_tls_index == TLS_OUT_OF_INDEXES)
...@@ -325,6 +329,10 @@ static void ExternalContextBase_ctor(ExternalContextBase *this) ...@@ -325,6 +329,10 @@ static void ExternalContextBase_ctor(ExternalContextBase *this)
memset(this, 0, sizeof(*this)); memset(this, 0, sizeof(*this));
this->context.vtable = &MSVCRT_ExternalContextBase_vtable; this->context.vtable = &MSVCRT_ExternalContextBase_vtable;
this->id = InterlockedIncrement(&context_id); this->id = InterlockedIncrement(&context_id);
create_default_scheduler();
this->scheduler.scheduler = &default_scheduler->scheduler;
call_Scheduler_Reference(&default_scheduler->scheduler);
} }
/* ?Alloc@Concurrency@@YAPAXI@Z */ /* ?Alloc@Concurrency@@YAPAXI@Z */
...@@ -834,7 +842,7 @@ Scheduler* __cdecl CurrentScheduler_Get(void) ...@@ -834,7 +842,7 @@ Scheduler* __cdecl CurrentScheduler_Get(void)
create_default_scheduler(); create_default_scheduler();
context->scheduler.scheduler = &default_scheduler->scheduler; context->scheduler.scheduler = &default_scheduler->scheduler;
ThreadScheduler_Reference(default_scheduler); call_Scheduler_Reference(&default_scheduler->scheduler);
return &default_scheduler->scheduler; return &default_scheduler->scheduler;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment