From 0cdaa709676809d368cab23cfd10e6b147b4f38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 22 May 2012 11:01:14 +0200 Subject: implement eiotas_spin_require_particle and eiotas_spin_release_particle --- src/lib/eiotas_spin.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lib/eiotas_spin.c b/src/lib/eiotas_spin.c index b10a6a3..3b14c96 100644 --- a/src/lib/eiotas_spin.c +++ b/src/lib/eiotas_spin.c @@ -22,6 +22,7 @@ #include "eiotas_spin.h" #include "eiotas_iota.h" +#include "eiotas_particle.h" #include "eiotas_private.h" EAPI Eiotas_Spin* eiotas_spin_add(const char* name, unsigned int step) @@ -59,3 +60,20 @@ EAPI void eiotas_spin_free(Eiotas_Spin *spin) free(spin); } +EAPI Eiotas_Particle* eiotas_spin_require_particle(Eiotas_Spin *spin) +{ + Eiotas_Particle *particle; + if(eina_array_count(spin->free_particles)>0) { + particle = eina_array_pop(spin->free_particles); + } else { + particle = (Eiotas_Particle*)eiotas_particle_alloc(); + } + return particle; +} + +EAPI Eiotas_Particle* eiotas_spin_release_particle(Eiotas_Spin *spin, Eiotas_Particle *particle) +{ + // TODO particle->reset(); + eina_array_push(spin->free_particles,particle); +} + -- cgit v1.1-2-g2b99