diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-21 23:04:55 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-21 23:04:55 +0200 |
commit | 14731017aeea0a078e45691d3f87fa78b731cbde (patch) | |
tree | 12b3598409d3bd1fc8345d7c49056ffe9dd9d09a /src | |
parent | 0de28b0aeff284eced9d9b63dd3126a8a12ee98c (diff) | |
download | edoors-14731017aeea0a078e45691d3f87fa78b731cbde.zip edoors-14731017aeea0a078e45691d3f87fa78b731cbde.tar.gz |
implement eiotas_spin_add and eiotas_spin_free
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/eiotas_spin.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/src/lib/eiotas_spin.c b/src/lib/eiotas_spin.c index 296db70..9080dd4 100644 --- a/src/lib/eiotas_spin.c +++ b/src/lib/eiotas_spin.c @@ -21,19 +21,48 @@ #endif #include "eiotas_spin.h" +#include "eiotas_iota.h" #include "eiotas_private.h" -EAPI Eiotas_Spin* -eiotas_spin_add(const char* name, unsigned int step) +EAPI Eiotas_Spin* eiotas_spin_add(const char* name, unsigned int step) { - // TODO - return NULL; + BUILD_INSTANCE(Eiotas_Spin,spin); + + if(name==NULL) { + ERR("name can't be NULL"); + return NULL; + } + + if(eiotas_iota_init(&spin->room.iota,name,NULL,EIOTAS_TYPE_SPIN)) { + return NULL; + } + + spin->room.links = NULL; /* not used */ + spin->room.children = eina_hash_stringshared_new((Eina_Free_Cb)&eiotas_iota_free); + spin->free_particles = eina_array_new(step); + spin->sys_fifo = eina_array_new(step); + spin->app_fifo = eina_array_new(step); + + return spin; } -EAPI void -eiotas_spin_free(Eiotas_Spin *spin) +EAPI void eiotas_spin_free(Eiotas_Spin *spin) { + unsigned int i; + Eiotas_Particle *particle; + Eina_Array_Iterator iterator; + DBG("Spin free 0x%X",spin); - // TODO + + eiotas_iota_desinit(&spin->room.iota); + eina_hash_free(spin->room.children); + EINA_ARRAY_ITER_NEXT(spin->free_particles, i, particle, iterator) eiotas_particle_free(particle); + EINA_ARRAY_ITER_NEXT(spin->sys_fifo, i, particle, iterator) eiotas_particle_free(particle); + EINA_ARRAY_ITER_NEXT(spin->app_fifo, i, particle, iterator) eiotas_particle_free(particle); + eina_array_free(spin->free_particles); + eina_array_free(spin->sys_fifo); + eina_array_free(spin->app_fifo); + + free(spin); } |