Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

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:

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 environment, link the C++ part of libacaio.lib library with multi-threaded msvcrt runtime library. Use /MT or /MTd compiler option.