Commit 13ea8a83 authored by Niels Möller's avatar Niels Möller
Browse files

* src/io.c (lsh_oop_time_callback): New function.

(lsh_oop_register_callout): New function.
(lsh_oop_cancel_callout): New function.
(do_kill_callout): New function.
(io_callout): Deleted delay argument, as delays are not currently

* src/io.c (io_final): Call gc_final. That makes sure that all
callbacks are cancelled. Updated callers to not use gc_final, only

Rev: src/io.c:1.150
Rev: src/io.h:1.81
parent 5ff9d581
......@@ -244,6 +244,38 @@ lsh_oop_cancel_write_fd(struct lsh_fd *fd)
static void *
lsh_oop_time_callback(oop_source *source UNUSED,
struct timeval time UNUSED, void *data)
CAST(lsh_callout, callout, (struct lsh_object *) data);
trace("lsh_oop_time_callback: action: %t\n",
callout->super.alive = 0;
static void
lsh_oop_register_callout(struct lsh_callout *callout)
if (callout->super.alive)
source->on_time(source, OOP_TIME_NOW, lsh_oop_time_callback, callout);
static void
lsh_oop_cancel_callout(struct lsh_callout *callout)
if (callout->super.alive)
source->cancel_time(source, OOP_TIME_NOW, lsh_oop_time_callback, callout);
/* Calls trigged by a signal handler. */
/* GABA:
......@@ -261,9 +293,7 @@ lsh_oop_cancel_write_fd(struct lsh_fd *fd)
(name lsh_callout)
(super resource)
(next object lsh_callout)
(action object lsh_callback)))
;; (when . time_t)
/* FIXME: With liboop, we should not need this object, we'd only need
......@@ -634,16 +664,29 @@ io_signal_handler(int signum,
return &handler->super;
static void
do_kill_callout(struct resource *s)
CAST(lsh_callout, self, s);
if (self->super.alive)
self->super.alive = 0;
/* Delays not implemented. */
struct resource *
io_callout(UINT32 delay UNUSED,
struct lsh_callback *action)
io_callout(struct lsh_callback *action)
NEW(lsh_callout, self);
init_resource(&self->super, NULL);
init_resource(&self->super, do_kill_callout);
self->action = action;
return &self->super;
......@@ -254,8 +254,7 @@ io_signal_handler(int signum,
struct lsh_callback *action);
struct resource *
io_callout(UINT32 delay,
struct lsh_callback *action);
io_callout(struct lsh_callback *action);
int blocking_read(int fd, struct read_handler *r);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment