# Template Class async_class

This topic only applies to Windows* OS.

Intel's C++ asynchronous I/O class implementation contains two main classes within the async namespace: the async_class template class and the thread_control base class.

The header/typedef definitions are as follows:

    namespace async {

    template<class A>
    class async_class:
    public thread_control, public A
    }

The template class async_class inherits support for asynchronous execution of I/O operations that are integrated within the base thread_control class.

All functionality to control asynchronous execution of a queue of STL stream operations is encapsulated in the base class thread_control and is inherited by template class async_class.

In most cases it is enough to add the header file aiostream.h to the source file and declare the file object as an instance of the new template class `async:async_class`. The initial stream class must be the parameter for the template class. Consequently, the defined output operator `<<` and input operator `>>` are executed asynchronously.

### Note

The header file aiostream.h includes all necessary declarations for the STL stream I/O operations to add asynchronous functionality of the thread_control class. It also contains the necessary declarations of extensions for the standard C++ STL streams I/O operations: output operator `>>` and input operator `<<`.

You can call synchronization method wait() to wait for completion of any I/O operations with the file object. If the wait() method is not called explicitly, it is called implicitly in the object destructor.

## Public Interface of Template Class async_class

The following methods define the public interface of the template class async_class:

- get_last_operation_id()
- wait()
- get_status()
- get_last_error()
- get_error_operation_id()
- stop_queue()
- resume_queue()
- clear_queue()

## Library Restrictions

Intel's C++ asynchronous I/O template class does not control the integrity or validity of the objects during asynchronous operation. Such control should be done by the user.

For application stability in the Visual Studio 2003 environment, link the C++ part of libacaio.lib library with multi-threaded msvcrt run-time library. Use /MT or /MTd compiler option.

Parent topic: Intel's C++ Asynchronous I/O Class for Windows* Operating Systems

## See Also

Example of Using async_class Template Class