diff options
author | Michael Brown | 2008-06-12 22:47:19 +0200 |
---|---|---|
committer | Michael Brown | 2010-06-22 15:40:09 +0200 |
commit | a03dd97e6b4c6d1d30ac9dc7e63f87402434d9bc (patch) | |
tree | b02a2bf151bfd212bea20ae7ac208c64157a0895 /src/core/job.c | |
parent | [interface] Expand object interface to allow for polymorphic interfaces (diff) | |
download | ipxe-a03dd97e6b4c6d1d30ac9dc7e63f87402434d9bc.tar.gz ipxe-a03dd97e6b4c6d1d30ac9dc7e63f87402434d9bc.tar.xz ipxe-a03dd97e6b4c6d1d30ac9dc7e63f87402434d9bc.zip |
[interface] Convert all job-control interfaces to generic interfaces
Remove job-control as an interface type, and replace job-control
interfaces with generic interfaces supporting the close() method.
(Both done() and kill() are absorbed into the function of close();
kill() is merely close(-ECANCELED).)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/job.c')
-rw-r--r-- | src/core/job.c | 85 |
1 files changed, 21 insertions, 64 deletions
diff --git a/src/core/job.c b/src/core/job.c index ffc0057f..ac4e43e7 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -28,70 +28,27 @@ FILE_LICENCE ( GPL2_OR_LATER ); * */ -void job_done ( struct job_interface *job, int rc ) { - struct job_interface *dest = job_get_dest ( job ); - - job_unplug ( job ); - dest->op->done ( dest, rc ); - job_put ( dest ); -} - -void job_kill ( struct job_interface *job ) { - struct job_interface *dest = job_get_dest ( job ); - - job_unplug ( job ); - dest->op->kill ( dest ); - job_put ( dest ); -} - -void job_progress ( struct job_interface *job, - struct job_progress *progress ) { - struct job_interface *dest = job_get_dest ( job ); - - dest->op->progress ( dest, progress ); - job_put ( dest ); -} - -/**************************************************************************** - * - * Helper methods - * - * These functions are designed to be used as methods in the - * job_interface_operations table. - * - */ - -void ignore_job_done ( struct job_interface *job __unused, int rc __unused ) { - /* Nothing to do */ -} - -void ignore_job_kill ( struct job_interface *job __unused ) { - /* Nothing to do */ -} - -void ignore_job_progress ( struct job_interface *job __unused, - struct job_progress *progress ) { - memset ( progress, 0, sizeof ( *progress ) ); -} - -/** Null job control interface operations */ -struct job_interface_operations null_job_ops = { - .done = ignore_job_done, - .kill = ignore_job_kill, - .progress = ignore_job_progress, -}; - /** - * Null job control interface + * Get job progress * - * This is the interface to which job control interfaces are connected - * when unplugged. It will never generate messages, and will silently - * absorb all received messages. + * @v intf Object interface + * @v progress Progress data to fill in */ -struct job_interface null_job = { - .intf = { - .dest = &null_job.intf, - .refcnt = NULL, - }, - .op = &null_job_ops, -}; +void job_progress ( struct interface *intf, struct job_progress *progress ) { + struct interface *dest; + job_progress_TYPE ( void * ) *op = + intf_get_dest_op ( intf, job_progress, &dest ); + void *object = intf_object ( dest ); + + DBGC ( INTF_COL ( intf ), "INTF " INTF_INTF_FMT " job_progress\n", + INTF_INTF_DBG ( intf, dest ) ); + + if ( op ) { + op ( object, progress ); + } else { + /* Default is to mark progress as zero */ + memset ( progress, 0, sizeof ( *progress ) ); + } + + intf_put ( dest ); +} |