Skip to content

Commit

Permalink
Merge #25: Obliterate Boost
Browse files Browse the repository at this point in the history
10b5c69 Obliterate Boost (Vasil Dimov)
f4112b7 Switch from C++14 to C++17 (Vasil Dimov)

Pull request description:

  * While it may be possible to refactor the code in a way that it does
    not use any `optional` types, like in a616312, fb73b81, 138ad67,
    5724a2c, that would be error prone and would require bigger changes.
    Switch from C++14 to C++17 instead and replace `boost::optional` with
    `std::optional`.

  * Removing `boost::current_exception_diagnostic_information()` - if the
    caught exception is an instance of `std::exception`, use its `what()`
    method. Otherwise don't provide extra diagnostic information. After
    all `boost::current_exception_diagnostic_information()` would return
    "No diagnostic information available." if it is not `std::exception`
    or `boost::exception`.

  * Clean up any mentions of Boost from README.md and CMakeLists.txt.

Top commit has no ACKs.

Tree-SHA512: fc2c504823fa1baa82912100944bbf6e43a8ffebc8bb974bd737f1b2c15433a85f37166595225745e7f8a4b8019f77a8813743bef7b8b7bb270af72e388ccd4f
  • Loading branch information
ryanofsky committed Mar 5, 2020
2 parents f2ea4b9 + 10b5c69 commit c0e3a50
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
10 changes: 4 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ project("Libmultiprocess" CXX)
include(CMakePushCheckState)
include(CTest)
include(CheckCXXSourceCompiles)
find_package(Boost)
find_package(CapnProto REQUIRED)
find_package(Threads REQUIRED)

Expand Down Expand Up @@ -64,11 +63,10 @@ target_include_directories(multiprocess PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>
${CAPNP_INCLUDE_DIRECTORY}
${Boost_INCLUDE_DIR})
${CAPNP_INCLUDE_DIRECTORY})
set_target_properties(multiprocess PROPERTIES
PUBLIC_HEADER "${MP_PUBLIC_HEADERS}"
CXX_STANDARD 14
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES)
install(TARGETS multiprocess EXPORT Multiprocess ARCHIVE DESTINATION lib PUBLIC_HEADER DESTINATION include/mp)

Expand All @@ -83,7 +81,7 @@ target_link_libraries(mpgen PRIVATE Threads::Threads)
target_link_libraries(mpgen PRIVATE multiprocess)
set_target_properties(mpgen PROPERTIES
INSTALL_RPATH_USE_LINK_PATH TRUE
CXX_STANDARD 14
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES)
install(TARGETS mpgen EXPORT Multiprocess RUNTIME DESTINATION bin)

Expand Down Expand Up @@ -135,7 +133,7 @@ if(BUILD_TESTING AND TARGET CapnProto::kj-test)
target_link_libraries(mptest PRIVATE Threads::Threads)
target_link_libraries(mptest PRIVATE multiprocess)
set_target_properties(mptest PROPERTIES
CXX_STANDARD 14
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES)
add_test(NAME mptest COMMAND mptest)
endif()
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ _libmultiprocess_ is currently compatible with sandboxing but could add platform

## Installation

Installation currently requires boost[*] and Cap'n Proto:
Installation currently requires Cap'n Proto:

```sh
apt install libboost-dev libcapnp-dev capnproto
brew install boost capnp
dnf install boost-devel capnproto
apt install libcapnp-dev capnproto
brew install capnp
dnf install capnproto

Installation steps are:

Expand All @@ -46,5 +46,3 @@ make
make all test
make install
```

[*] The boost dependency should be eliminated; it is solely for `boost::optional`.
4 changes: 2 additions & 2 deletions include/mp/proxy-io.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

#include <mp/proxy.capnp.h>

#include <boost/exception/diagnostic_information.hpp>
#include <boost/optional/optional.hpp>
#include <capnp/rpc-twoparty.h>

#include <assert.h>
#include <functional>
#include <map>
#include <memory>
#include <sstream>
#include <string>

namespace mp {
Expand Down
17 changes: 11 additions & 6 deletions include/mp/proxy-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#define MP_PROXY_TYPES_H

#include <mp/proxy-io.h>

#include <exception>
#include <optional>
#include <set>
#include <vector>

Expand Down Expand Up @@ -178,7 +181,7 @@ class Emplace
Value& m_value;

template <typename T, typename... Params>
static T& call(boost::optional<T>& value, Params&&... params)
static T& call(std::optional<T>& value, Params&&... params)
{
value.emplace(std::forward<Params>(params)...);
return *value;
Expand Down Expand Up @@ -227,7 +230,7 @@ class Emplace
};

template <typename LocalType, typename Input, typename DestValue>
void ReadFieldUpdate(TypeList<boost::optional<LocalType>>,
void ReadFieldUpdate(TypeList<std::optional<LocalType>>,
InvokeContext& invoke_context,
Input&& input,
DestValue&& value)
Expand Down Expand Up @@ -832,7 +835,7 @@ LocalType BuildPrimitive(InvokeContext& invoke_context,
}

template <typename LocalType, typename Value, typename Output>
void CustomBuildField(TypeList<boost::optional<LocalType>>,
void CustomBuildField(TypeList<std::optional<LocalType>>,
Priority<1>,
InvokeContext& invoke_context,
Value&& value,
Expand Down Expand Up @@ -1038,7 +1041,7 @@ template <typename Accessor, typename LocalType, typename ServerContext, typenam
void DefaultPassField(TypeList<LocalType>, ServerContext& server_context, Fn&& fn, Args&&... args)
{
InvokeContext& invoke_context = server_context;
boost::optional<Decay<LocalType>> param;
std::optional<Decay<LocalType>> param;
const auto& params = server_context.call_context.getParams();
MaybeReadField(std::integral_constant<bool, Accessor::in>(), TypeList<LocalType>(), invoke_context,
Make<StructField, Accessor>(params), Emplace<decltype(param)>(param));
Expand Down Expand Up @@ -1434,9 +1437,11 @@ kj::Promise<void> serverInvoke(Server& server, CallContext& call_context, Fn fn)
server.m_connection.m_loop.log() << "IPC server send response #" << req << " " << TypeName<Results>()
<< " " << LogEscape(call_context.getResults().toString());
});
} catch (const std::exception& e) {
server.m_connection.m_loop.log() << "IPC server unhandled exception: " << e.what();
throw;
} catch (...) {
server.m_connection.m_loop.log()
<< "IPC server unhandled exception " << boost::current_exception_diagnostic_information();
server.m_connection.m_loop.log() << "IPC server unhandled exception";
throw;
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkgconfig/libmultiprocess.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Description: Multiprocess IPC library
Version: 0.0

Libs: -L${libdir} -lmultiprocess -L${capnp_prefix}/lib -lcapnp-rpc -lcapnp -lkj-async -lkj -pthread -lpthread
Cflags: -std=c++14 -I${includedir} -I${capnp_prefix}/include -pthread
Cflags: -std=c++17 -I${includedir} -I${capnp_prefix}/include -pthread

0 comments on commit c0e3a50

Please sign in to comment.