From d29a2d705fe2bc4579b791e44fbfcf7885df7d37 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Tue, 8 Sep 2015 13:53:49 +0100 Subject: [PATCH] Rename boost.monad to boost.outcome --- .gitmodules | 7 ++- build/afio.vcxproj | 2 +- doc/afio.qbk | 2 +- doc/design_rationale.qbk | 6 +-- .../group_async_file_io_dispatcher.qbk | 2 +- doc/quickstart.qbk | 20 +++---- doc/release_notes.qbk | 2 +- example/workshop_atomic_updates_afio.ipp | 12 ++--- example/workshop_final_afio.ipp | 28 +++++----- example/workshop_naive.ipp | 16 +++--- example/workshop_naive_afio.ipp | 20 +++---- example/workshop_naive_async_afio.ipp | 8 +-- include/boost/afio/monad | 1 - include/boost/afio/outcome | 1 + include/boost/afio/v2/afio.hpp | 4 +- include/boost/afio/v2/config.hpp | 54 +++++++++---------- include/boost/afio/v2/detail/impl/afio.ipp | 2 +- 17 files changed, 93 insertions(+), 94 deletions(-) delete mode 160000 include/boost/afio/monad create mode 160000 include/boost/afio/outcome diff --git a/.gitmodules b/.gitmodules index adcffffd3..c73dba953 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,11 +2,10 @@ path = include/boost/afio/bindlib url = https://github.com/ned14/Boost.BindLib.git branch = master -[submodule "include/boost/afio/monad"] - path = include/boost/afio/monad - url = https://github.com/ned14/boost.monad.git - branch = master [submodule "include/boost/afio/v1/branch"] path = include/boost/afio/v1/branch url = https://github.com/BoostGSoC13/boost.afio.git branch = v1.3_Boost_v1.58_branch +[submodule "include/boost/afio/outcome"] + path = include/boost/afio/outcome + url = https://github.com/ned14/boost.outcome.git diff --git a/build/afio.vcxproj b/build/afio.vcxproj index fed358f6d..55cc52a64 100644 --- a/build/afio.vcxproj +++ b/build/afio.vcxproj @@ -90,7 +90,7 @@ afio.exe WIN32;_DEBUG;$(NMakePreprocessorDefinitions) - ..\..\..\b2 address-model=64 link=static ../test --link-test -j 8 pch=off --test=../example/workshop_final_afio.cpp + ..\..\..\b2 address-model=64 link=static ../test --link-test -j 8 ..\..\..\b2 address-model=64 -a $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);..\..\.. diff --git a/doc/afio.qbk b/doc/afio.qbk index 3b4bcc5d6..bbadaf523 100644 --- a/doc/afio.qbk +++ b/doc/afio.qbk @@ -25,7 +25,7 @@ [def __boost__ Boost] [def __boost_afio__ Boost.AFIO] [def __boost_bindlib__ [@https://github.com/ned14/Boost.APIBind Boost.APIBind]] -[def __boost_monad__ [@https://ned14.github.io/boost.monad/group__future__promise.html Boost.Monad]] +[def __boost_outcome__ [@https://ned14.github.io/boost.outcome/group__future__promise.html Boost.Outcome]] [def __triplegit__ TripleGit] [def __fileurl__ file:///] [def __dash__ \u2014] diff --git a/doc/design_rationale.qbk b/doc/design_rationale.qbk index b64e3478d..617e29ff6 100644 --- a/doc/design_rationale.qbk +++ b/doc/design_rationale.qbk @@ -18,7 +18,7 @@ an opaque abstract base class. When constructed using __afio_make_dispatcher__ y namespace the dispatcher will dispatch onto. You can create your own custom `dispatcher` implementations for some URI regex pattern too. * AFIO provides its own custom future type `afio::__afio_op__` which [*always] represents a future `handle_ptr` plus an optional `T` -which is usually `void` (hence defaulting `T` to `void`). This custom future type is implemented using __boost_monad__'s lightweight +which is usually `void` (hence defaulting `T` to `void`). This custom future type is implemented using __boost_outcome__'s lightweight monadic future factory toolkit, and therefore provides all the C++ 1z Concurrency TS and __boost_thread__ extensions including continuations and wait composure. Note that lightweight futures can carry an `error_code` as well as an `exception_ptr`, and therefore much of the need for non-throwing `error_code` taking API overloads is not needed (though any function not returning a future still @@ -46,7 +46,7 @@ API which consumes a future can throw (unless you know for a fact the future is not errored). [note Gathering error states from many futures at once is made easier using the `when_all_p()` -(when all propagating) extended wait composure function from __boost_monad__ __dash__ this +(when all propagating) extended wait composure function from __boost_outcome__ __dash__ this propagates any error in any of the entry futures into the composed output future, thus saving you having to check the futures for errors by hand.] @@ -180,7 +180,7 @@ to keep the continuations information per future. This had the big advantage tha futures could be used, but it came with many other problems, mainly performance and code complexity related. An additional problem was that the Concurrency TS had moved on considerably since 2012, and AFIO's emulation was now significantly out of date. -For v1.4 a new lightweight future-promise factory toolkit library called __boost_monad__ was written between the +For v1.4 a new lightweight future-promise factory toolkit library called __boost_outcome__ was written between the end of C++ Now (May) and the beginning of the AFIO peer review (July) which makes easy the writing of arbitrarily customisable future-promises for C++ which: diff --git a/doc/generated/group_async_file_io_dispatcher.qbk b/doc/generated/group_async_file_io_dispatcher.qbk index 3fa7970d6..e2ac213f8 100644 --- a/doc/generated/group_async_file_io_dispatcher.qbk +++ b/doc/generated/group_async_file_io_dispatcher.qbk @@ -52,7 +52,7 @@ URIs currently supported by AFIO: [heading Synopsis] -``BOOST_AFIO_DECL monad make_dispatcher(std::string uri = "file : / / /", file_flags flagsforce = file_flags::none, file_flags flagsmask = file_flags::none, +``BOOST_AFIO_DECL outcome 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())`` [heading Parameters] diff --git a/doc/quickstart.qbk b/doc/quickstart.qbk index 208656e30..d30528fd3 100644 --- a/doc/quickstart.qbk +++ b/doc/quickstart.qbk @@ -66,9 +66,9 @@ to v2 you mean v2 and nothing but v2. If you just wanted the current AFIO, simpl `boost::afio` as with other libraries, this picks up whatever the current configuration and version of AFIO is. -The `monad<>` comes from __boost_monad__ which is a dependency of __boost_afio__. It has an identical +The `outcome<>` comes from __boost_outcome__ which is a dependency of __boost_afio__. It has an identical API to `std::future<>` or more rather `boost::future<>`, so simply treat it as an always ready future. -`monad<>` here can return a shared pointer to the iostream, or empty (item not found), or an error, or +`outcome<>` here can return a shared pointer to the iostream, or empty (item not found), or an error, or an exception as you can see in this example use case: [workshop_use_naive] @@ -77,7 +77,7 @@ A perfectly straightforward and simple way of implementing `data_store` using pu [workshop_naive] -Note that `monad` implicitly consumes any `T`, `std::error_code`, `std::exception_ptr` or `empty`, hence +Note that `outcome` implicitly consumes any `T`, `std::error_code`, `std::exception_ptr` or `empty`, hence the ability to return any of those directly. This very simple solution assumes that the key-value store is a directory in the current path called ["store] and @@ -156,7 +156,7 @@ quickly __dash__ indeed far faster than copying 4Kb of memory and often quicker complete before scheduling the next write in order to report any errors which occurred during the write. This is the first use of asynchronous i/o in this tutorial. AFIO provides a custom `future` type extending -the lightweight monadic futures framework in __boost_monad__, so you get all the +the lightweight monadic futures framework in __boost_outcome__, so you get all the [@http://www.drdobbs.com/parallel/improving-futures-and-callbacks-in-c-to/240004255 C++ 1z Concurrency TS extensions], [@http://blogs.msdn.com/b/vcblog/archive/2014/11/12/resumable-functions-in-c.aspx C++ 1z coroutines support] and [@http://www.boost.org/doc/html/thread/synchronization.html#thread.synchronization.futures Boost.Thread future extensions] in the AFIO custom `future<>`. There are also many @@ -179,7 +179,7 @@ additional extensions beyond what Boost.Thread or the Concurrency TS provides, i [section:naive_afio_async 3. World's simplest named blob store in AFIO (asynchronous)] Let's see the same exact thing as in the last section, but this time with a fully asynchronous public interface. -Instead of returning `monad<>`, we now return `shared_future<>`: +Instead of returning `outcome<>`, we now return `shared_future<>`: [workshop_naive_async_afio_interface] @@ -188,7 +188,7 @@ convert from their allowed monadic input types without you needing to write `mak Concurrency TS. You may be interested to know that the benchmarking harness code is 100% identical for all three of these -implementations. This is because `monad<>` is sufficiently API-identical to `future<>` that identical code can drive all +implementations. This is because `outcome<>` is sufficiently API-identical to `future<>` that identical code can drive all three implementations. `write()` is now implemented by scheduling the file to be opened for write access and attaching a continuation @@ -203,7 +203,7 @@ a second continuation to return the input stream. The below pattern is 100% pure soon-to-be-standardised Concurrency TS future continuations which can be easily coroutinised automatically on a C++ 1z Coroutines supporting compiler (simply insert `await` before any AFIO `async_XXX` function). Apart from the fact that -__boost_monad__ lightweight futures also provide an `error_code` transport, there is nothing below which wouldn't +__boost_outcome__ lightweight futures also provide an `error_code` transport, there is nothing below which wouldn't work with an upcoming standard C++ library (unless the TS changes substantially, which is very unlikely at this late stage). @@ -262,7 +262,7 @@ implementation is far faster and will [*always] be faster than AFIO if you do a is pretty much this benchmark in a nutshell. [note This peer review edition of AFIO v1.40 uses a mocked up v1.40 API based on the v1.3 series engine. Performance -of this mockup will be considerably below the final v1.40 engine written using __boost_monad__'s lightweight futures.] +of this mockup will be considerably below the final v1.40 engine written using __boost_outcome__'s lightweight futures.] A design which makes better use of AFIO is one which is asynchronous throughout and which avoids file opens and closes (['tip:] always avoid file opens period if you want fast filesystem performance, they are always very slow due @@ -795,10 +795,10 @@ deallocate the rest. So let's look at our new interface file. It looks pretty similar to before, the only real change is the many new private member variable `handle_ptr`'s to the store files described above. Another change is that we now return -a `monad` for writing but a `shared_future` for reading __dash__ this is because as explained +a `outcome` for writing but a `shared_future` for reading __dash__ this is because as explained earlier, writes are now fully buffered to memory before being hashed and committed as a transaction, so by explicitly returning a monad we are saying that this is now a synchronous operation (one could just return an already ready -shared future, but this method makes public API assurances, and because a __boost_monad__ future is a monad, +shared future, but this method makes public API assurances, and because a __boost_outcome__ future is a monad, your code will likely not even notice). [workshop_final_interface] diff --git a/doc/release_notes.qbk b/doc/release_notes.qbk index eed51dfd0..23fa36b15 100644 --- a/doc/release_notes.qbk +++ b/doc/release_notes.qbk @@ -15,7 +15,7 @@ version to enter Boost if accepted] This peer review edition of AFIO v1.4 has been ["mocked up] with an API which should very closely resemble the eventual API in the v1.4 engine which will be rewritten to use the just written -lightweight future-promise factory toolkit in forthcoming __boost_monad__. It is, however, +lightweight future-promise factory toolkit in forthcoming __boost_outcome__. It is, however, still in fact the mature v1.3 engine with a faked wrapper API simulating the v1.4 engine. Known deviations from the eventual v1.4 release: diff --git a/example/workshop_atomic_updates_afio.ipp b/example/workshop_atomic_updates_afio.ipp index d9f1ff18b..14a98e234 100644 --- a/example/workshop_atomic_updates_afio.ipp +++ b/example/workshop_atomic_updates_afio.ipp @@ -1,7 +1,7 @@ //[workshop_atomic_updates_afio_interface namespace afio = BOOST_AFIO_V2_NAMESPACE; namespace filesystem = BOOST_AFIO_V2_NAMESPACE::filesystem; -using BOOST_MONAD_V1_NAMESPACE::lightweight_futures::shared_future; +using BOOST_OUTCOME_V1_NAMESPACE::lightweight_futures::shared_future; class data_store { @@ -32,7 +32,7 @@ public: //[workshop_atomic_updates_afio3] namespace asio = BOOST_AFIO_V2_NAMESPACE::asio; -using BOOST_MONAD_V1_NAMESPACE::empty; +using BOOST_OUTCOME_V1_NAMESPACE::empty; using BOOST_AFIO_V2_NAMESPACE::error_code; using BOOST_AFIO_V2_NAMESPACE::generic_category; @@ -160,7 +160,7 @@ struct odirectstream : public std::ostream //[workshop_atomic_updates_afio1] namespace asio = BOOST_AFIO_V2_NAMESPACE::asio; -using BOOST_MONAD_V1_NAMESPACE::empty; +using BOOST_OUTCOME_V1_NAMESPACE::empty; using BOOST_AFIO_V2_NAMESPACE::error_code; using BOOST_AFIO_V2_NAMESPACE::generic_category; @@ -218,7 +218,7 @@ shared_future data_store::lookup(std::string name) noexcept // When it completes, call this continuation return h.then([](afio::future<> &_h) -> shared_future { // If file didn't open, return the error or exception immediately - BOOST_MONAD_PROPAGATE(_h); + BOOST_OUTCOME_PROPAGATE(_h); size_t length=(size_t) _h->lstat(afio::metadata_flags::size).st_size; // Is a memory map more appropriate? if(length>=128*1024) @@ -236,7 +236,7 @@ shared_future data_store::lookup(std::string name) noexcept // When the read completes call this continuation return h.then([buffer, length](const afio::future<> &h) -> shared_future { // If read failed, return the error or exception immediately - BOOST_MONAD_PROPAGATE(h); + BOOST_OUTCOME_PROPAGATE(h); data_store::istream ret(std::make_shared(h.get_handle(), buffer, length)); return ret; }); @@ -276,7 +276,7 @@ shared_future data_store::write(std::string name) noexcept // When it completes, call this continuation return h.then([](const afio::future<> &h) -> shared_future { // If file didn't open, return the error or exception immediately - BOOST_MONAD_PROPAGATE(h); + BOOST_OUTCOME_PROPAGATE(h); // Create an ostream which directly uses the file. data_store::ostream ret(std::make_shared(h.get_handle())); return std::move(ret); diff --git a/example/workshop_final_afio.ipp b/example/workshop_final_afio.ipp index c4856b1a6..7a1e424b4 100644 --- a/example/workshop_final_afio.ipp +++ b/example/workshop_final_afio.ipp @@ -3,8 +3,8 @@ //[workshop_final_interface namespace afio = BOOST_AFIO_V2_NAMESPACE; namespace filesystem = BOOST_AFIO_V2_NAMESPACE::filesystem; -using BOOST_MONAD_V1_NAMESPACE::monad; -using BOOST_MONAD_V1_NAMESPACE::lightweight_futures::shared_future; +using BOOST_OUTCOME_V1_NAMESPACE::outcome; +using BOOST_OUTCOME_V1_NAMESPACE::lightweight_futures::shared_future; class data_store { @@ -27,7 +27,7 @@ public: // Type used for lookup using lookup_result_type = shared_future; // Type used for write - using write_result_type = monad; + using write_result_type = outcome; // Disposition flags static constexpr size_t writeable = (1<<0); @@ -38,7 +38,7 @@ public: // Look up item named name for reading, returning an istream for the item shared_future lookup(std::string name) noexcept; // Look up item named name for writing, returning an ostream for that item - monad write(std::string name) noexcept; + outcome write(std::string name) noexcept; }; //] @@ -46,7 +46,7 @@ public: namespace asio = BOOST_AFIO_V2_NAMESPACE::asio; using BOOST_AFIO_V2_NAMESPACE::error_code; using BOOST_AFIO_V2_NAMESPACE::generic_category; -using BOOST_MONAD_V1_NAMESPACE::monad; +using BOOST_OUTCOME_V1_NAMESPACE::outcome; // A special allocator of highly efficient file i/o memory using file_buffer_type = std::vector>; @@ -118,7 +118,7 @@ struct data_store::index last_good_ondisk_index_info() : offset(0), size(0) { } }; // Finds the last good index in the store - monad find_last_good_ondisk_index(afio::handle_ptr h) noexcept + outcome find_last_good_ondisk_index(afio::handle_ptr h) noexcept { last_good_ondisk_index_info ret; error_code ec; @@ -262,11 +262,11 @@ start_linear_scan: //] //[workshop_final3] // Loads the index from the store - monad load(afio::handle_ptr h) noexcept + outcome load(afio::handle_ptr h) noexcept { // If find_last_good_ondisk_index() returns error or exception, return those, else // initialise ondisk_index_info to monad.get() - BOOST_MONAD_AUTO(ondisk_index_info, find_last_good_ondisk_index(h)); + BOOST_OUTCOME_AUTO(ondisk_index_info, find_last_good_ondisk_index(h)); error_code ec; try { @@ -291,7 +291,7 @@ start_linear_scan: //] //[workshop_final4] // Writes the index to the store - monad store(afio::handle_ptr rwh, afio::handle_ptr appendh) noexcept + outcome store(afio::handle_ptr rwh, afio::handle_ptr appendh) noexcept { error_code ec; std::vector ondisk_regions; @@ -351,7 +351,7 @@ start_linear_scan: do { // Is this index stale? - BOOST_MONAD_AUTO(ondisk_index_info, find_last_good_ondisk_index(rwh)); + BOOST_OUTCOME_AUTO(ondisk_index_info, find_last_good_ondisk_index(rwh)); if(ondisk_index_info.offset!=offset_loaded_from) { // A better conflict resolution strategy might check to see if deltas @@ -394,7 +394,7 @@ start_linear_scan: //] //[workshop_final5] // Reloads the index if needed - monad refresh(afio::handle_ptr h) noexcept + outcome refresh(afio::handle_ptr h) noexcept { static afio::off_t last_size; error_code ec; @@ -595,7 +595,7 @@ shared_future data_store::lookup(std::string name) noexcept { try { - BOOST_MONAD_PROPAGATE(_index->refresh(_index_store)); + BOOST_OUTCOME_PROPAGATE(_index->refresh(_index_store)); auto it=_index->key_to_region.find(name); if(_index->key_to_region.end()==it) return error_code(ENOENT, generic_category()); // not found @@ -607,7 +607,7 @@ shared_future data_store::lookup(std::string name) noexcept // When the read completes call this continuation return h.then([buffer, length](const afio::future<> &h) -> shared_future { // If read failed, return the error or exception immediately - BOOST_MONAD_PROPAGATE(h); + BOOST_OUTCOME_PROPAGATE(h); data_store::istream ret(std::make_shared(h.get_handle(), buffer, (size_t) length)); return ret; }); @@ -618,7 +618,7 @@ shared_future data_store::lookup(std::string name) noexcept } } -monad data_store::write(std::string name) noexcept +outcome data_store::write(std::string name) noexcept { try { diff --git a/example/workshop_naive.ipp b/example/workshop_naive.ipp index 23cdae02b..0739095be 100644 --- a/example/workshop_naive.ipp +++ b/example/workshop_naive.ipp @@ -1,6 +1,6 @@ //[workshop_naive_interface namespace filesystem = BOOST_AFIO_V2_NAMESPACE::filesystem; -using BOOST_MONAD_V1_NAMESPACE::monad; +using BOOST_OUTCOME_V1_NAMESPACE::outcome; class data_store { @@ -12,9 +12,9 @@ public: // Type used for write streams using ostream = std::shared_ptr; // Type used for lookup - using lookup_result_type = monad; + using lookup_result_type = outcome; // Type used for write - using write_result_type = monad; + using write_result_type = outcome; // Disposition flags static constexpr size_t writeable = (1<<0); @@ -23,14 +23,14 @@ public: data_store(size_t flags = 0, filesystem::path path = "store"); // Look up item named name for reading, returning a std::istream for the item if it exists - monad lookup(std::string name) noexcept; + outcome lookup(std::string name) noexcept; // Look up item named name for writing, returning an ostream for that item - monad write(std::string name) noexcept; + outcome write(std::string name) noexcept; }; //] //[workshop_naive] -using BOOST_MONAD_V1_NAMESPACE::empty; +using BOOST_OUTCOME_V1_NAMESPACE::empty; using BOOST_AFIO_V2_NAMESPACE::error_code; using BOOST_AFIO_V2_NAMESPACE::generic_category; @@ -53,7 +53,7 @@ data_store::data_store(size_t flags, filesystem::path path) : _store_path(std::m { } -monad data_store::lookup(std::string name) noexcept +outcome data_store::lookup(std::string name) noexcept { if(!is_valid_name(name)) return error_code(EINVAL, generic_category()); @@ -70,7 +70,7 @@ monad data_store::lookup(std::string name) noexcept } } -monad data_store::write(std::string name) noexcept +outcome data_store::write(std::string name) noexcept { if(!_writeable) return error_code(EROFS, generic_category()); diff --git a/example/workshop_naive_afio.ipp b/example/workshop_naive_afio.ipp index 2e87873f8..cdec22e40 100644 --- a/example/workshop_naive_afio.ipp +++ b/example/workshop_naive_afio.ipp @@ -1,7 +1,7 @@ //[workshop_naive_afio_interface namespace afio = BOOST_AFIO_V2_NAMESPACE; namespace filesystem = BOOST_AFIO_V2_NAMESPACE::filesystem; -using BOOST_MONAD_V1_NAMESPACE::monad; +using BOOST_OUTCOME_V1_NAMESPACE::outcome; class data_store { @@ -13,9 +13,9 @@ public: // Type used for write streams using ostream = std::shared_ptr; // Type used for lookup - using lookup_result_type = monad; + using lookup_result_type = outcome; // Type used for write - using write_result_type = monad; + using write_result_type = outcome; // Disposition flags static constexpr size_t writeable = (1<<0); @@ -24,15 +24,15 @@ public: data_store(size_t flags = 0, afio::path path = "store"); // Look up item named name for reading, returning a std::istream for the item if it exists - monad lookup(std::string name) noexcept; + outcome lookup(std::string name) noexcept; // Look up item named name for writing, returning an ostream for that item - monad write(std::string name) noexcept; + outcome write(std::string name) noexcept; }; //] //[workshop_naive_afio2] namespace asio = BOOST_AFIO_V2_NAMESPACE::asio; -using BOOST_MONAD_V1_NAMESPACE::empty; +using BOOST_OUTCOME_V1_NAMESPACE::empty; using BOOST_AFIO_V2_NAMESPACE::error_code; using BOOST_AFIO_V2_NAMESPACE::generic_category; @@ -156,7 +156,7 @@ struct odirectstream : public std::ostream //[workshop_naive_afio1] namespace asio = BOOST_AFIO_V2_NAMESPACE::asio; -using BOOST_MONAD_V1_NAMESPACE::empty; +using BOOST_OUTCOME_V1_NAMESPACE::empty; using BOOST_AFIO_V2_NAMESPACE::error_code; using BOOST_AFIO_V2_NAMESPACE::generic_category; @@ -178,7 +178,7 @@ data_store::data_store(size_t flags, afio::path path) _store=afio::dir(std::move(path), afio::file_flags::create); // throws if there was an error } -monad data_store::lookup(std::string name) noexcept +outcome data_store::lookup(std::string name) noexcept { if(!is_valid_name(name)) return error_code(EINVAL, generic_category()); @@ -208,7 +208,7 @@ monad data_store::lookup(std::string name) noexcept } } -monad data_store::write(std::string name) noexcept +outcome data_store::write(std::string name) noexcept { if(!is_valid_name(name)) return error_code(EINVAL, generic_category()); @@ -226,7 +226,7 @@ monad data_store::write(std::string name) noexcept if(ec) return ec; // Create an ostream which directly uses the mapped file. - return monad(std::make_shared(std::move(h))); + return outcome(std::make_shared(std::move(h))); } catch (...) { diff --git a/example/workshop_naive_async_afio.ipp b/example/workshop_naive_async_afio.ipp index f216eaaee..c9bcf02fe 100644 --- a/example/workshop_naive_async_afio.ipp +++ b/example/workshop_naive_async_afio.ipp @@ -1,7 +1,7 @@ //[workshop_naive_async_afio_interface namespace afio = BOOST_AFIO_V2_NAMESPACE; namespace filesystem = BOOST_AFIO_V2_NAMESPACE::filesystem; -using BOOST_MONAD_V1_NAMESPACE::lightweight_futures::shared_future; +using BOOST_OUTCOME_V1_NAMESPACE::lightweight_futures::shared_future; class data_store { @@ -180,7 +180,7 @@ shared_future data_store::lookup(std::string name) noexcept // When it completes, call this continuation return h.then([](afio::future<> &_h) -> shared_future { // If file didn't open, return the error or exception immediately - BOOST_MONAD_PROPAGATE(_h); + BOOST_OUTCOME_PROPAGATE(_h); size_t length=(size_t) _h->lstat(afio::metadata_flags::size).st_size; // Is a memory map more appropriate? if(length>=128*1024) @@ -198,7 +198,7 @@ shared_future data_store::lookup(std::string name) noexcept // When the read completes call this continuation return h.then([buffer, length](const afio::future<> &h) -> shared_future { // If read failed, return the error or exception immediately - BOOST_MONAD_PROPAGATE(h); + BOOST_OUTCOME_PROPAGATE(h); data_store::istream ret(std::make_shared(h.get_handle(), buffer, length)); return ret; }); @@ -224,7 +224,7 @@ shared_future data_store::write(std::string name) noexcept // When it completes, call this continuation return h.then([](const afio::future<> &h) -> shared_future { // If file didn't open, return the error or exception immediately - BOOST_MONAD_PROPAGATE(h); + BOOST_OUTCOME_PROPAGATE(h); // Create an ostream which directly uses the file. data_store::ostream ret(std::make_shared(h.get_handle())); return std::move(ret); diff --git a/include/boost/afio/monad b/include/boost/afio/monad deleted file mode 160000 index b7486938c..000000000 --- a/include/boost/afio/monad +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b7486938c5b947b257e3e6374436ec7e25c51ed7 diff --git a/include/boost/afio/outcome b/include/boost/afio/outcome new file mode 160000 index 000000000..33d037c46 --- /dev/null +++ b/include/boost/afio/outcome @@ -0,0 +1 @@ +Subproject commit 33d037c468477ca582dac11953339d186f00677a diff --git a/include/boost/afio/v2/afio.hpp b/include/boost/afio/v2/afio.hpp index b69302b53..25c78be25 100644 --- a/include/boost/afio/v2/afio.hpp +++ b/include/boost/afio/v2/afio.hpp @@ -2413,9 +2413,9 @@ URIs currently supported by AFIO: } */ #ifdef DOXYGEN_SHOULD_SKIP_THIS -BOOST_AFIO_HEADERS_ONLY_FUNC_SPEC monad make_dispatcher(std::string uri="file : / / /", file_flags flagsforce = file_flags::none, file_flags flagsmask = file_flags::none, std::shared_ptr threadpool = process_threadpool()) noexcept; +BOOST_AFIO_HEADERS_ONLY_FUNC_SPEC outcome make_dispatcher(std::string uri="file : / / /", file_flags flagsforce = file_flags::none, file_flags flagsmask = file_flags::none, std::shared_ptr threadpool = process_threadpool()) noexcept; #else -BOOST_AFIO_HEADERS_ONLY_FUNC_SPEC monad make_dispatcher(std::string uri="file:///", file_flags flagsforce=file_flags::none, file_flags flagsmask=file_flags::none, std::shared_ptr threadpool = process_threadpool()) noexcept; +BOOST_AFIO_HEADERS_ONLY_FUNC_SPEC outcome make_dispatcher(std::string uri="file:///", file_flags flagsforce=file_flags::none, file_flags flagsmask=file_flags::none, std::shared_ptr threadpool = process_threadpool()) noexcept; #endif namespace detail diff --git a/include/boost/afio/v2/config.hpp b/include/boost/afio/v2/config.hpp index f6cead68a..26fd17961 100644 --- a/include/boost/afio/v2/config.hpp +++ b/include/boost/afio/v2/config.hpp @@ -93,10 +93,10 @@ DEALINGS IN THE SOFTWARE. // Default to the C++ 11 STL for atomic, chrono, mutex and thread except on Mingw32 #if (defined(BOOST_AFIO_USE_BOOST_THREAD) && BOOST_AFIO_USE_BOOST_THREAD) || (defined(__MINGW32__) && !defined(__MINGW64__) && !defined(__MINGW64_VERSION_MAJOR)) -# if defined(BOOST_MONAD_USE_BOOST_THREAD) && BOOST_MONAD_USE_BOOST_THREAD != 1 +# if defined(BOOST_OUTCOME_USE_BOOST_THREAD) && BOOST_OUTCOME_USE_BOOST_THREAD != 1 # error You must configure Boost.Monad and Boost.AFIO to both use Boost.Thread together or both not at all. # endif -# define BOOST_MONAD_USE_BOOST_THREAD 1 +# define BOOST_OUTCOME_USE_BOOST_THREAD 1 # define BOOST_AFIO_V2_STL11_IMPL boost # ifndef BOOST_THREAD_VERSION # define BOOST_THREAD_VERSION 3 @@ -105,10 +105,10 @@ DEALINGS IN THE SOFTWARE. # error Boost.AFIO requires that Boost.Thread be configured to v3 or later # endif #else -# if defined(BOOST_MONAD_USE_BOOST_THREAD) && BOOST_MONAD_USE_BOOST_THREAD != 0 +# if defined(BOOST_OUTCOME_USE_BOOST_THREAD) && BOOST_OUTCOME_USE_BOOST_THREAD != 0 # error You must configure Boost.Monad and Boost.AFIO to both use Boost.Thread together or both not at all. # endif -# define BOOST_MONAD_USE_BOOST_THREAD 0 +# define BOOST_OUTCOME_USE_BOOST_THREAD 0 # define BOOST_AFIO_V2_STL11_IMPL std # ifndef BOOST_AFIO_USE_BOOST_THREAD # define BOOST_AFIO_USE_BOOST_THREAD 0 @@ -132,16 +132,16 @@ DEALINGS IN THE SOFTWARE. // If building standalone, use a local asio, else Boost #ifndef BOOST_AFIO_V2_ASIO_IMPL # if ASIO_STANDALONE -# if defined(BOOST_MONAD_USE_BOOST_ERROR_CODE) && BOOST_MONAD_USE_BOOST_ERROR_CODE != 0 +# if defined(BOOST_OUTCOME_USE_BOOST_ERROR_CODE) && BOOST_OUTCOME_USE_BOOST_ERROR_CODE != 0 # error You must configure Boost.Monad to use the STL error_code if using standalone ASIO # endif -# define BOOST_MONAD_USE_BOOST_ERROR_CODE 0 +# define BOOST_OUTCOME_USE_BOOST_ERROR_CODE 0 # define BOOST_AFIO_V2_ASIO_IMPL asio # else -# if defined(BOOST_MONAD_USE_BOOST_ERROR_CODE) && BOOST_MONAD_USE_BOOST_ERROR_CODE != 1 +# if defined(BOOST_OUTCOME_USE_BOOST_ERROR_CODE) && BOOST_OUTCOME_USE_BOOST_ERROR_CODE != 1 # error You must configure Boost.Monad to use the Boost error code if using Boost.ASIO # endif -# define BOOST_MONAD_USE_BOOST_ERROR_CODE 1 +# define BOOST_OUTCOME_USE_BOOST_ERROR_CODE 1 # define BOOST_AFIO_V2_ASIO_IMPL boost // Pull in Boost now before Monad does to avoid warnings caused by APIBind emulating Boost # include "boost/thread/future.hpp" @@ -373,26 +373,26 @@ namespace boost { namespace asio { BOOST_AFIO_V2_NAMESPACE_END #endif -#include "../monad/include/boost/monad.hpp" +#include "../outcome/include/boost/outcome.hpp" BOOST_AFIO_V2_NAMESPACE_BEGIN - using BOOST_MONAD_V1_NAMESPACE::is_lockable_locked; - using spins_to_sleep = BOOST_MONAD_V1_NAMESPACE::spins_to_sleep; - template using spins_to_yield = BOOST_MONAD_V1_NAMESPACE::spins_to_yield<_0>; - template using spins_to_loop = BOOST_MONAD_V1_NAMESPACE::spins_to_loop<_0, _1>; - using null_spin_policy = BOOST_MONAD_V1_NAMESPACE::null_spin_policy; - template using spinlockbase = BOOST_MONAD_V1_NAMESPACE::spinlockbase; - template using lockable_ptr = BOOST_MONAD_V1_NAMESPACE::lockable_ptr; - template class spinpolicy2=spins_to_loop<125>::policy, template class spinpolicy3=spins_to_yield<250>::policy, template class spinpolicy4=spins_to_sleep::policy> using spinlock = BOOST_MONAD_V1_NAMESPACE::spinlock; - template using monad = BOOST_MONAD_V1_NAMESPACE::monad; - template using result = BOOST_MONAD_V1_NAMESPACE::result; - template using option = BOOST_MONAD_V1_NAMESPACE::option; - template using lightweight_promise = BOOST_MONAD_V1_NAMESPACE::lightweight_futures::promise; - template using lightweight_future = BOOST_MONAD_V1_NAMESPACE::lightweight_futures::future; - template using is_lightweight_future = BOOST_MONAD_V1_NAMESPACE::lightweight_futures::is_future; - using BOOST_MONAD_V1_NAMESPACE::empty; - using BOOST_MONAD_V1_NAMESPACE::make_option; - using BOOST_MONAD_V1_NAMESPACE::monad_errc; - using BOOST_MONAD_V1_NAMESPACE::monad_category; + using BOOST_OUTCOME_V1_NAMESPACE::is_lockable_locked; + using spins_to_sleep = BOOST_OUTCOME_V1_NAMESPACE::spins_to_sleep; + template using spins_to_yield = BOOST_OUTCOME_V1_NAMESPACE::spins_to_yield<_0>; + template using spins_to_loop = BOOST_OUTCOME_V1_NAMESPACE::spins_to_loop<_0, _1>; + using null_spin_policy = BOOST_OUTCOME_V1_NAMESPACE::null_spin_policy; + template using spinlockbase = BOOST_OUTCOME_V1_NAMESPACE::spinlockbase; + template using lockable_ptr = BOOST_OUTCOME_V1_NAMESPACE::lockable_ptr; + template class spinpolicy2=spins_to_loop<125>::policy, template class spinpolicy3=spins_to_yield<250>::policy, template class spinpolicy4=spins_to_sleep::policy> using spinlock = BOOST_OUTCOME_V1_NAMESPACE::spinlock; + template using outcome = BOOST_OUTCOME_V1_NAMESPACE::outcome; + template using result = BOOST_OUTCOME_V1_NAMESPACE::result; + template using option = BOOST_OUTCOME_V1_NAMESPACE::option; + template using lightweight_promise = BOOST_OUTCOME_V1_NAMESPACE::lightweight_futures::promise; + template using lightweight_future = BOOST_OUTCOME_V1_NAMESPACE::lightweight_futures::future; + template using is_lightweight_future = BOOST_OUTCOME_V1_NAMESPACE::lightweight_futures::is_future; + using BOOST_OUTCOME_V1_NAMESPACE::empty; + using BOOST_OUTCOME_V1_NAMESPACE::make_option; + using BOOST_OUTCOME_V1_NAMESPACE::monad_errc; + using BOOST_OUTCOME_V1_NAMESPACE::monad_category; BOOST_AFIO_V2_NAMESPACE_END /////////////////////////////////////////////////////////////////////////////// diff --git a/include/boost/afio/v2/detail/impl/afio.ipp b/include/boost/afio/v2/detail/impl/afio.ipp index 303e2c52d..33b395ab0 100644 --- a/include/boost/afio/v2/detail/impl/afio.ipp +++ b/include/boost/afio/v2/detail/impl/afio.ipp @@ -3435,7 +3435,7 @@ BOOST_AFIO_HEADERS_ONLY_MEMFUNC_SPEC handle::mapped_file::~mapped_file() #endif } -BOOST_AFIO_HEADERS_ONLY_MEMFUNC_SPEC monad make_dispatcher(std::string uri, file_flags flagsforce, file_flags flagsmask, std::shared_ptr threadpool) noexcept +BOOST_AFIO_HEADERS_ONLY_MEMFUNC_SPEC outcome make_dispatcher(std::string uri, file_flags flagsforce, file_flags flagsmask, std::shared_ptr threadpool) noexcept { try {