Adde cothread context cleanup code

Original commit message from CVS:
Adde cothread context cleanup code
This commit is contained in:
Wim Taymans 2001-12-18 16:49:13 +00:00
parent 7cfd7c6d09
commit e279738a3f
2 changed files with 21 additions and 0 deletions

View file

@ -106,6 +106,26 @@ cothread_init (void)
return ctx;
}
void
cothread_free (cothread_context *ctx)
{
gint i;
for (i=0; i<ctx->nthreads; i++) {
#ifndef COTHREAD_ATOMIC
if (ctx->threads[i]->lock) {
g_mutex_unlock(ctx->threads[i]->lock);
g_mutex_free (ctx->threads[i]->lock);
}
#endif
if (i == 0)
g_free (ctx->threads[i]);
}
g_hash_table_destroy (ctx->data);
g_free (ctx);
}
/**
* cothread_create:
* @ctx: the cothread context

View file

@ -68,6 +68,7 @@ struct _cothread_state {
cothread_context* cothread_init (void);
cothread_state* cothread_create (cothread_context *ctx);
void cothread_free (cothread_context *ctx);
void cothread_setfunc (cothread_state *thread, cothread_func func,
int argc, char **argv);
int cothread_getcurrent (void);