ANN uint32_t gw_rand(uint32_t s[2]);
ANN void gw_seed(uint32_t s[2], const uint64_t);
ANN void handle(VM_Shred shred, const m_str effect);
-
+ANN bool unwind(const VM_Shred shred, const Symbol effect, const m_uint size);
#define BBQ_POS_MAX 16777216
static MFUN(gw_shred_exit) {
const VM_Shred s = ME(o);
if((m_int)s->tick->prev != -1)
- shreduler_remove(s->tick->shreduler, s, true);
+ shreduler_remove(s->tick->shreduler, s, true);
}
static MFUN(vm_shred_id) {
ANN static void shreduler_erase(const Shreduler s,
struct ShredTick_ *const tk) {
- MUTEX_LOCK(tk->self->mutex);
+ const VM_Shred shred = tk->self;
+ const m_uint size =
+ shred->info->frame.ptr ? vector_size(&shred->info->frame) : 0;
+ unwind(shred, (Symbol)-1, size);
+ MUTEX_LOCK(shred->mutex);
if (tk->parent) {
MUTEX_LOCK(tk->parent->self->mutex);
vector_rem2(&tk->parent->child, (vtype)tk->self);
MUTEX_UNLOCK(tk->parent->self->mutex);
}
if (tk->child.ptr) shreduler_child(&tk->child);
- vector_rem2(&s->active_shreds, (vtype)tk->self);
- MUTEX_UNLOCK(tk->self->mutex);
+ vector_rem2(&s->active_shreds, (vtype)shred);
+ MUTEX_UNLOCK(shred->mutex);
}
ANN void shreduler_remove(const Shreduler s, const VM_Shred out,
return true;
}
-ANN static bool unwind(const VM_Shred shred, const Symbol effect, const m_uint size) {
+ANN bool unwind(const VM_Shred shred, const Symbol effect, const m_uint size) {
const VM_Code code = shred->code;
if (code->live_values.ptr)
clean_values(shred);