job.h
Go to the documentation of this file.00001 #ifndef _GPXE_JOB_H
00002 #define _GPXE_JOB_H
00003
00004
00005
00006
00007
00008
00009
00010 FILE_LICENCE ( GPL2_OR_LATER );
00011
00012 #include <stddef.h>
00013 #include <gpxe/interface.h>
00014
00015
00016 struct job_progress {
00017
00018
00019
00020
00021
00022
00023
00024 unsigned long completed;
00025
00026
00027
00028
00029
00030
00031 unsigned long total;
00032 };
00033
00034 struct job_interface;
00035
00036
00037 struct job_interface_operations {
00038
00039
00040
00041
00042
00043 void ( * done ) ( struct job_interface *job, int rc );
00044
00045
00046
00047
00048 void ( * kill ) ( struct job_interface *job );
00049
00050
00051
00052
00053
00054 void ( * progress ) ( struct job_interface *job,
00055 struct job_progress *progress );
00056 };
00057
00058
00059 struct job_interface {
00060
00061 struct interface intf;
00062
00063 struct job_interface_operations *op;
00064 };
00065
00066 extern struct job_interface null_job;
00067 extern struct job_interface_operations null_job_ops;
00068
00069 extern void job_done ( struct job_interface *job, int rc );
00070 extern void job_kill ( struct job_interface *job );
00071 extern void job_progress ( struct job_interface *job,
00072 struct job_progress *progress );
00073
00074 extern void ignore_job_done ( struct job_interface *job, int rc );
00075 extern void ignore_job_kill ( struct job_interface *job );
00076 extern void ignore_job_progress ( struct job_interface *job,
00077 struct job_progress *progress );
00078
00079
00080
00081
00082
00083
00084
00085
00086 static inline void job_init ( struct job_interface *job,
00087 struct job_interface_operations *op,
00088 struct refcnt *refcnt ) {
00089 job->intf.dest = &null_job.intf;
00090 job->intf.refcnt = refcnt;
00091 job->op = op;
00092 }
00093
00094
00095
00096
00097
00098
00099
00100 static inline __attribute__ (( always_inline )) struct job_interface *
00101 intf_to_job ( struct interface *intf ) {
00102 return container_of ( intf, struct job_interface, intf );
00103 }
00104
00105
00106
00107
00108
00109
00110
00111 static inline __attribute__ (( always_inline )) struct job_interface *
00112 job_get_dest ( struct job_interface *job ) {
00113 return intf_to_job ( intf_get ( job->intf.dest ) );
00114 }
00115
00116
00117
00118
00119
00120
00121 static inline __attribute__ (( always_inline )) void
00122 job_put ( struct job_interface *job ) {
00123 intf_put ( &job->intf );
00124 }
00125
00126
00127
00128
00129
00130
00131
00132 static inline void job_plug ( struct job_interface *job,
00133 struct job_interface *dest ) {
00134 plug ( &job->intf, &dest->intf );
00135 }
00136
00137
00138
00139
00140
00141
00142
00143 static inline void job_plug_plug ( struct job_interface *a,
00144 struct job_interface *b ) {
00145 plug_plug ( &a->intf, &b->intf );
00146 }
00147
00148
00149
00150
00151
00152
00153 static inline void job_unplug ( struct job_interface *job ) {
00154 plug ( &job->intf, &null_job.intf );
00155 }
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 static inline void job_nullify ( struct job_interface *job ) {
00166 job->op = &null_job_ops;
00167 };
00168
00169 #endif