static inline Type dict_type(const Gwion gwion, const Type key, const Type val, const loc_t pos) {
char c[1024];
+ const m_str keyname = type2str(gwion, key, pos);
+ const m_str valname = type2str(gwion, key, pos);
sprintf(c, "Dict:[%s,%s]", key->name, val->name);
+ free_mstr(gwion->mp, keyname);
+ free_mstr(gwion->mp, valname);
return str2type(gwion, c, pos);
}
#endif
static CTOR(event_ctor) { vector_init(&EV_SHREDS(o)); }
-static DTOR(event_dtor) { vector_release(&EV_SHREDS(o)); }
+static DTOR(event_dtor) {
+ for (m_uint i = 0; i < vector_size(&EV_SHREDS(o)); i++) {
+ const VM_Shred sh = (VM_Shred)vector_at(&EV_SHREDS(o), i);
+ release(sh->info->me, sh);
+ }
+ vector_release(&EV_SHREDS(o));
+}
static INSTR(EventWait) {
POP_REG(shred, SZ_FLOAT);
const M_Object event = *(M_Object *)REG(-SZ_INT);
shreduler_remove(shred->tick->shreduler, shred, false);
+ shred->info->me->ref++;
const Vector v = &EV_SHREDS(event);
vector_add(v, (vtype)shred);
*(m_int *)REG(-SZ_INT) = 1;
shredule(sh->tick->shreduler, sh, GWION_EPSILON);
vector_rem(v, 0);
}
+ release(sh->info->me, sh);
}
ANN void broadcast(const M_Object o) {
for (m_uint i = 0; i < vector_size(&EV_SHREDS(o)); i++) {
const VM_Shred sh = (VM_Shred)vector_at(&EV_SHREDS(o), i);
shredule(sh->tick->shreduler, sh, GWION_EPSILON);
+ release(sh->info->me, sh);
}
vector_clear(&EV_SHREDS(o));
}
ANN static inline void child(const Shreduler s, const Vector v) {
for (m_uint i = vector_size(v) + 1; --i;) {
- const VM_Shred child = (VM_Shred)vector_at(v, i - 1);
- struct ShredTick_ *const tk = child->tick;
+ const VM_Shred shred = (VM_Shred)vector_at(v, i - 1);
+ struct ShredTick_ *const tk = shred->tick;
tk_remove(s, tk);
shreduler_erase(s, tk);
}
shred->info->frame.ptr ? vector_size(&shred->info->frame) : 0;
unwind(shred, (Symbol)-1, size);
vector_rem2(&s->active_shreds, (vtype)shred);
+ release(shred->info->me, shred);
}
ANN void shreduler_remove(const Shreduler s, const VM_Shred out,
tk_remove(s, tk);
if (likely(!erase)) tk->prev = tk->next = NULL;
else {
- shreduler_erase(s, tk);
if (tk->parent) vector_rem2(&tk->parent->child, (vtype)out);
- release(out->info->me, out);
+ shreduler_erase(s, tk);
}
MUTEX_UNLOCK(s->mutex);
}