change yield so that it doesn't handle events in a non-handler thread(!)

svn: r1487
This commit is contained in:
Matthew Flatt 2005-12-02 14:19:08 +00:00
parent 592c47e4be
commit 1aba007321
3 changed files with 24 additions and 5 deletions

View File

@ -1016,7 +1016,7 @@ static int check_eventspace_inactive(void *_c)
void mred_wait_eventspace(void)
{
MrEdContext * volatile c;
MrEdContext *c;
c = MrEdGetContext();
if (c && (c->handler_running == scheme_current_thread)) {
wxDispatchEventsUntilWaitable(check_eventspace_inactive, c, NULL);
@ -1025,6 +1025,9 @@ void mred_wait_eventspace(void)
int mred_current_thread_is_handler(void *ctx)
{
if (!ctx)
ctx = MrEdGetContext();
return (((MrEdContext *)ctx)->handler_running == scheme_current_thread);
}

View File

@ -2098,21 +2098,35 @@ static Scheme_Object *queue_callback(int argc, Scheme_Object **argv)
void *wxSchemeYield(void *sema)
{
int is_handler;
if (!wait_symbol) {
wxREGGLOB(wait_symbol);
wait_symbol = scheme_intern_symbol("wait");
}
is_handler = mred_current_thread_is_handler(NULL);
if (sema == wait_symbol) {
mred_wait_eventspace();
return scheme_true;
if (is_handler) {
mred_wait_eventspace();
return scheme_true;
} else
return scheme_false;
} else if (sema) {
if (!scheme_is_evt((Scheme_Object *)sema))
scheme_wrong_type("yield", "evt or 'wait", -1, 0, (Scheme_Object **)&sema);
return wxDispatchEventsUntilWaitable((wxDispatch_Check_Fun)NULL, NULL, (Scheme_Object *)sema);
if (is_handler)
return wxDispatchEventsUntilWaitable((wxDispatch_Check_Fun)NULL, NULL, (Scheme_Object *)sema);
else {
Scheme_Object *a[1];
a[0] = sema;
scheme_sync(1, a);
return scheme_false;
}
} else {
if (wxYield())
if (is_handler && wxYield())
return scheme_true;
else
return scheme_false;

View File

@ -41,6 +41,8 @@ extern int wxGetPreference(const char *name, int *res);
extern int wxIsUserMainEventspace(Scheme_Object *o);
extern int mred_current_thread_is_handler(void *ctx);
void wxscheme_early_gl_init(void);
#ifdef MPW_CPLUS