Non-blocking I/O operations

ABT-IO provides an API to issue I/O operations in a non-blocking manner and wait for completion later. The following code examplifies this feature,

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <abt-io.h>

int main(int argc, char** argv)
    // Argobots must be initialized, either with ABT_init
    // or with margo_init, thallium::engine, or thallium::abt.
    ABT_init(argc, argv);

    // abt_io_init takes the number of ES to create as a parameter.
    abt_io_instance_id abtio = abt_io_init(2);

    // open a file
    int fd = abt_io_open(abtio, "test.txt", O_WRONLY | O_APPEND | O_CREAT, 0600);

    // write to the file without blocking
    ssize_t ret;
    abt_io_op_t* op = abt_io_pwrite_nb(abtio, fd, "This is a test", 14, 0, &ret);

    // wait for the request to be completed

    // free the request

    // close the file
    abt_io_close(abtio, fd);

    // ABT-IO must be finalized before Argobots it finalized.


    return 0;

Every ABT-IO function described in Issuing I/O operations has a corresponding non-blocking variant. These non-blocking variants take an additional parameter which is a pointer to the returned value (will be set when the operation has completed) and return a pointer to an abt_io_op_t object.

The user can then use abt_io_op_wait to wait for the operation to complete, and abt_io_op_free to free the operation once completed.