2 * $Id: rb_job.c 9 2004-06-19 19:53:47Z tilman $
4 * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <Ecore_Job.h>
26 #include "rb_ecore_job.h"
36 static void on_job (void *data)
38 RbEcoreJob *job = data;
40 rb_funcall ((VALUE) job->cb, rb_intern ("call"), 0);
44 static VALUE c_init (VALUE self)
46 RbEcoreJob *job = NULL;
48 Data_Get_Struct (self, RbEcoreJob, job);
50 job->cb = (void *) rb_block_proc ();
51 job->job = ecore_job_add (on_job, job);
56 static void c_free (RbEcoreJob *job)
58 if (job->job && !job->deleted)
59 ecore_job_del (job->job);
64 static VALUE c_new (VALUE klass)
69 self = Data_Make_Struct (klass, RbEcoreJob, NULL, c_free, job);
71 rb_obj_call_init (self, 0, NULL);
76 static VALUE c_delete (VALUE self)
79 RbEcoreJob *job = NULL;
81 Data_Get_Struct (self, RbEcoreJob, job);
83 if (job->job && !job->deleted) {
84 ecore_job_del (job->job);
95 cEcoreJob = rb_define_class_under (mJob, "Job", rb_cObject);
97 rb_define_singleton_method (cEcoreJob, "new", c_new, 0);
98 rb_define_method (cEcoreJob, "initialize", c_init, 0);
99 rb_define_method (cEcoreJob, "delete", c_delete, 0);