summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown2007-01-16 09:10:54 +0100
committerMichael Brown2007-01-16 09:10:54 +0100
commitff8528ea9a69ca2ef6cfbed0b7a1283e165aabe6 (patch)
treebae0e953c128a5d49bedd2f502325b938078635f /src/include
parentWhen a network device is specified to tcpip_tx() or it's children, treat (diff)
downloadipxe-ff8528ea9a69ca2ef6cfbed0b7a1283e165aabe6.tar.gz
ipxe-ff8528ea9a69ca2ef6cfbed0b7a1283e165aabe6.tar.xz
ipxe-ff8528ea9a69ca2ef6cfbed0b7a1283e165aabe6.zip
Create and use async_block() macro; it cuts down on the visual overhead
of blocking on asynchronous operations, when that isn't an important aspect of the code.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gpxe/async.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/include/gpxe/async.h b/src/include/gpxe/async.h
index d3b075b92..b1ca1a1cc 100644
--- a/src/include/gpxe/async.h
+++ b/src/include/gpxe/async.h
@@ -167,4 +167,40 @@ static inline aid_t async_init_orphan ( struct async *async ) {
return async_init ( async, &orphan_async_operations, NULL );
}
+/**
+ * Execute and block on an asynchronous operation
+ *
+ * @v async_temp Temporary asynchronous operation structure to use
+ * @v START Code used to start the asynchronous operation
+ * @ret rc Return status code
+ *
+ * This is a notational shorthand for writing
+ *
+ * async_init_orphan ( &async_temp );
+ * if ( ( rc = START ) == 0 )
+ * async_wait ( &async_temp );
+ * if ( rc != 0 ) {
+ * ...handle failure...
+ * }
+ *
+ * and allows you instead to write
+ *
+ * if ( ( rc = async_block ( &async_temp, START ) ) != 0 ) {
+ * ...handle failure...
+ * }
+ *
+ * The argument START is a code snippet; it should initiate an
+ * asynchronous operation as a child of @c async_temp and return an
+ * error status code if it failed to do so (e.g. due to malloc()
+ * failure).
+ */
+#define async_block( async_temp, START ) ( { \
+ int rc; \
+ \
+ async_init_orphan ( async_temp ); \
+ if ( ( rc = START ) == 0 ) \
+ async_wait ( async_temp, &rc, 1 ); \
+ rc; \
+ } )
+
#endif /* _GPXE_ASYNC_H */