# mco_aio_start

Adjust Asynchronous IO parameters for persistent databases.

### Prototype

        MCO_RET	mco_aio_start(	mco_size_t max_queue_length, mco_size_t n_workers);

### Arguments

max_queue_length | The maximum size of the AIO buffer
n_workers | The number of AIO threads (Note that, regardless of the value of this argument, the runtime won't exceed the number of databases created in a process; i,e, the runtime does not allow more then one AIO thread to serve a database)

### Description

> This function allows the application to adjust the AIO buffer size and number of threads used for AIO. It must be called before `mco_db_open_dev()` and, if called, the companion function `mco_aio_stop()` should be called when database write activity is finished. By default one AIO thread is started for each database and the default queue size is set to 10007. Sometimes it could be beneficial to change the number of AIO threads (for example is the database is comprised of multiple physical IO devices, or is resided on a RAID) and/or the queue size. However note that the number of I/O threads won't exceed the number of databases created in a process,

### Return Codes

MCO_S_OK | The AIO parameters were successfully set

### Example

        Application snippet:

        const char * dbname = "SimpleDb";

        int main(int argc, char* argv[])
        {
            mco_db_h db;
            MCO_RET rc;
            mco_device_t       dev;
            mco_db_params_t    db_params;

            if( (rc = mco_runtime_start()) != MCO_S_OK)
                exit(-1);

            ...
            rc = mco_aio_start( 20000, 2 );

            rc = mco_db_open_dev( dbname, simpledb_get_dictionary(), &dev, 1, &db_params);
            ...
            rc = mco_db_connect(dbname, &db);
            ...
            mco_aio_stop();
        }

### Files

Header file:
mco.h
Source file:
mcoaio.c
Library:
libmcovtdsk.a
Header file:
mco.h
Source file:
mcovtmem.c
Library:
libmcovtmem.a