/* * New collapsed (a)synchronous interface. * * If the IO is asynchronous (i.e. it has notify.fn), you must either unplug * the queue with blk_unplug() some time later or set REQ_SYNC in io_req->bi_rw. If you fail to do one of these, the IO will be submitted to * the disk after q->unplug_delay, which defaults to 3ms in blk-settings.c. */ int dm_io(struct dm_io_request *io_req, unsigned num_regions, struct dm_io_region *where, unsigned long *sync_error_bits) { int r; struct dpages dp; r = dp_init(io_req, &dp); if (r) return r; if (!io_req->notify.fn) return sync_io(io_req->client, num_regions, where, io_req->bi_rw, &dp, sync_error_bits); return async_io(io_req->client, num_regions, where, io_req->bi_rw, &dp, io_req->notify.fn, io_req->notify.context); }
int hpx_main() { { // Initiate an asynchronous IO operation wait for it to complete without // blocking any of the HPX thread-manager threads. hpx::lcos::future<int> f = async_io("Write this string to std::cout"); // This will suspend the current HPX thread until the IO operation is // finished. int result = f.get(); // Print the returned result. hpx::cout << "HPX-thread: The asynchronous IO operation returned: " << result << "\n" << hpx::flush; } return hpx::finalize(); // Initiate shutdown of the runtime system. }
static int async_write(struct async *as) { return async_io(as, 0 /* No read. */); }
static int async_read_write(struct async *as) { return async_io(as, 1 /* Read too. */); }