mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
Optimized the way resetting buffer states occurs and fixed thread::kill so
threads actually die as they are supposed to.
This commit is contained in:
parent
8012a408b8
commit
f287e78030
4 changed files with 17 additions and 9 deletions
|
@ -47,6 +47,7 @@ typedef struct gib_event_s {
|
||||||
|
|
||||||
void GIB_Thread_Add (gib_thread_t *thread);
|
void GIB_Thread_Add (gib_thread_t *thread);
|
||||||
void GIB_Thread_Remove (gib_thread_t *thread);
|
void GIB_Thread_Remove (gib_thread_t *thread);
|
||||||
|
void GIB_Thread_Delete (gib_thread_t *thread);
|
||||||
gib_thread_t *GIB_Thread_Find (unsigned long int id);
|
gib_thread_t *GIB_Thread_Find (unsigned long int id);
|
||||||
gib_thread_t *GIB_Thread_New (void);
|
gib_thread_t *GIB_Thread_New (void);
|
||||||
void GIB_Thread_Execute (void);
|
void GIB_Thread_Execute (void);
|
||||||
|
|
|
@ -618,12 +618,16 @@ GIB_Thread_Kill_f (void)
|
||||||
id);
|
id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Set error condition on the top of the stack so the thread will exit
|
|
||||||
// We can't simply nuke the thread, as it would cause the stack walker
|
// If we are currently running this thread, set an error state so we exit it cleanly
|
||||||
// to segfault if a thread kills itself.
|
// if it were simply nuked, a crash would result
|
||||||
for (cur = thread->cbuf;
|
for (cur = thread->cbuf; cur->down && cur->down->state != CBUF_STATE_JUNK; cur = cur->down)
|
||||||
cur->down && cur->down->state != CBUF_STATE_JUNK; cur = cur->down);
|
if (cur == cbuf_active) {
|
||||||
cur->state = CBUF_STATE_ERROR;
|
cur->state = CBUF_STATE_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GIB_Thread_Remove (thread);
|
||||||
|
GIB_Thread_Delete (thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ GIB_Thread_New (void)
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
GIB_Thread_Delete (gib_thread_t * thread)
|
GIB_Thread_Delete (gib_thread_t * thread)
|
||||||
{
|
{
|
||||||
Cbuf_DeleteStack (thread->cbuf);
|
Cbuf_DeleteStack (thread->cbuf);
|
||||||
|
|
|
@ -132,6 +132,7 @@ Cbuf_Reset (cbuf_t *cbuf)
|
||||||
{
|
{
|
||||||
cbuf->resumetime = 0.0;
|
cbuf->resumetime = 0.0;
|
||||||
cbuf->args->argc = 0;
|
cbuf->args->argc = 0;
|
||||||
|
cbuf->state = CBUF_STATE_NORMAL;
|
||||||
if (cbuf->interpreter->reset)
|
if (cbuf->interpreter->reset)
|
||||||
cbuf->interpreter->reset (cbuf);
|
cbuf->interpreter->reset (cbuf);
|
||||||
}
|
}
|
||||||
|
@ -168,7 +169,6 @@ void
|
||||||
Cbuf_Execute (cbuf_t *cbuf)
|
Cbuf_Execute (cbuf_t *cbuf)
|
||||||
{
|
{
|
||||||
cbuf_active = cbuf;
|
cbuf_active = cbuf;
|
||||||
cbuf->state = CBUF_STATE_NORMAL;
|
|
||||||
cbuf->interpreter->execute (cbuf);
|
cbuf->interpreter->execute (cbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,13 +188,16 @@ Cbuf_Execute_Stack (cbuf_t *cbuf)
|
||||||
Cbuf_Execute (sp);
|
Cbuf_Execute (sp);
|
||||||
if (sp->state) {
|
if (sp->state) {
|
||||||
if (sp->state == CBUF_STATE_STACK) {
|
if (sp->state == CBUF_STATE_STACK) {
|
||||||
|
sp->state = CBUF_STATE_NORMAL;
|
||||||
sp = sp->down;
|
sp = sp->down;
|
||||||
continue;
|
continue;
|
||||||
} else if (sp->state == CBUF_STATE_ERROR)
|
} else if (sp->state == CBUF_STATE_ERROR)
|
||||||
break;
|
break;
|
||||||
else
|
else {
|
||||||
|
sp->state = CBUF_STATE_NORMAL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
sp->state = CBUF_STATE_JUNK;
|
sp->state = CBUF_STATE_JUNK;
|
||||||
sp = sp->up;
|
sp = sp->up;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue