Home | Libraries | People | FAQ | More |
Instatiates the best available async_file_io_dispatcher implementation for this system for the given uri.
Note that the number of threads in the threadpool supplied is the maximum non-async op queue depth (e.g. file opens, closes etc.). For fast SSDs, there isn't much gain after eight-sixteen threads, so the process threadpool is set to eight by default. For slow hard drives, or worse, SANs, a queue depth of 64 or higher might deliver significant benefits.
URIs currently supported by AFIO:
file:///
The dispatcher
will refer to the local filesystem of this machine.
BOOST_AFIO_DECL outcome<dispatcher_ptr> make_dispatcher(std::string uri = "file : / / /", file_flags flagsforce = file_flags::none, file_flags flagsmask = file_flags::none, std::shared_ptr< thread_source > threadpool = process_threadpool())
Type |
Concept |
Name |
Description |
---|---|---|---|
std::string |
uri |
Where to open the dispatcher upon. |
|
file_flags |
flagsforce |
The flags to bitwise OR with any opened file flags. Used to force on certain flags. |
|
file_flags |
flagsmask |
The flags to bitwise AND with any opened file flags. Used to force off certain flags. |
|
std::shared_ptr< thread_source > |
threadpool |
The threadpool instance to use for asynchronous dispatch. |
A shared_ptr to the best available async_file_io_dispatcher implementation for this system for the given uri.
#include <boost/afio/v2/afio.hpp>
// Create a dispatcher instance auto dispatcher = boost::afio::make_dispatcher().get(); // Schedule an asynchronous call of some function with some bound set of arguments auto helloworld = dispatcher->call(boost::afio::future<>() /* no precondition */, [](std::string text) -> int { std::cout << text << std::endl; return 42; }, std::string("Hello world")); // Schedule as asynchronous call of some function to occur only after helloworld // completes auto addtovalue = dispatcher->call(helloworld, [&helloworld]() -> int { return helloworld.get() + 1; }); // Print the result returned by the future for the lambda, which will be 43 std::cout << "addtovalue() returned " << addtovalue.get() << std::endl;