Skip to content

Commit 5e5b6c3

Browse files
committed
Obliterate Boost
* 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.
1 parent 49a9637 commit 5e5b6c3

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ project("Libmultiprocess" CXX)
77
include(CMakePushCheckState)
88
include(CTest)
99
include(CheckCXXSourceCompiles)
10-
find_package(Boost)
1110
find_package(CapnProto)
1211
find_package(Threads REQUIRED)
1312

@@ -62,11 +61,10 @@ target_include_directories(multiprocess PUBLIC
6261
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
6362
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
6463
$<INSTALL_INTERFACE:include>
65-
${CAPNP_INCLUDE_DIRECTORY}
66-
${Boost_INCLUDE_DIR})
64+
${CAPNP_INCLUDE_DIRECTORY})
6765
set_target_properties(multiprocess PROPERTIES
6866
PUBLIC_HEADER "${MP_PUBLIC_HEADERS}"
69-
CXX_STANDARD 14
67+
CXX_STANDARD 17
7068
CXX_STANDARD_REQUIRED YES)
7169
install(TARGETS multiprocess EXPORT Multiprocess ARCHIVE DESTINATION lib PUBLIC_HEADER DESTINATION include/mp)
7270

@@ -78,7 +76,7 @@ target_link_libraries(mpgen PRIVATE -L${capnp_LIBRARY_DIRS} capnpc)
7876
target_link_libraries(mpgen PRIVATE multiprocess)
7977
set_target_properties(mpgen PROPERTIES
8078
INSTALL_RPATH_USE_LINK_PATH TRUE
81-
CXX_STANDARD 14
79+
CXX_STANDARD 17
8280
CXX_STANDARD_REQUIRED YES)
8381
install(TARGETS mpgen EXPORT Multiprocess RUNTIME DESTINATION bin)
8482

@@ -126,7 +124,7 @@ if(BUILD_TESTING)
126124
target_link_libraries(mptest PRIVATE CapnProto::kj-test)
127125
target_link_libraries(mptest PRIVATE multiprocess)
128126
set_target_properties(mptest PROPERTIES
129-
CXX_STANDARD 14
127+
CXX_STANDARD 17
130128
CXX_STANDARD_REQUIRED YES)
131129
add_test(NAME mptest COMMAND mptest)
132130
endif()

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ _libmultiprocess_ is currently compatible with sandboxing but could add platform
2929

3030
## Installation
3131

32-
Installation currently requires boost[*] and Cap'n Proto:
32+
Installation currently requires Cap'n Proto:
3333

3434
```sh
35-
apt install libboost-dev libcapnp-dev capnproto
36-
brew install boost capnp
37-
dnf install boost-devel capnproto
35+
apt install libcapnp-dev capnproto
36+
brew install capnp
37+
dnf install capnproto
3838

3939
Installation steps are:
4040

@@ -46,5 +46,3 @@ make
4646
make test
4747
make install
4848
```
49-
50-
[*] The boost dependency should be eliminated; it is solely for `boost::optional`.

include/mp/proxy-io.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
#include <mp/proxy.capnp.h>
1212

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

1715
#include <functional>
16+
#include <map>
1817
#include <memory>
18+
#include <sstream>
1919
#include <string>
2020

2121
namespace mp {

include/mp/proxy-types.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#define MP_PROXY_TYPES_H
77

88
#include <mp/proxy-io.h>
9+
10+
#include <exception>
11+
#include <optional>
912
#include <set>
1013
#include <vector>
1114

@@ -178,7 +181,7 @@ class Emplace
178181
Value& m_value;
179182

180183
template <typename T, typename... Params>
181-
static T& call(boost::optional<T>& value, Params&&... params)
184+
static T& call(std::optional<T>& value, Params&&... params)
182185
{
183186
value.emplace(std::forward<Params>(params)...);
184187
return *value;
@@ -227,7 +230,7 @@ class Emplace
227230
};
228231

229232
template <typename LocalType, typename Input, typename DestValue>
230-
void ReadFieldUpdate(TypeList<boost::optional<LocalType>>,
233+
void ReadFieldUpdate(TypeList<std::optional<LocalType>>,
231234
InvokeContext& invoke_context,
232235
Input&& input,
233236
DestValue&& value)
@@ -832,7 +835,7 @@ LocalType BuildPrimitive(InvokeContext& invoke_context,
832835
}
833836

834837
template <typename LocalType, typename Value, typename Output>
835-
void CustomBuildField(TypeList<boost::optional<LocalType>>,
838+
void CustomBuildField(TypeList<std::optional<LocalType>>,
836839
Priority<1>,
837840
InvokeContext& invoke_context,
838841
Value&& value,
@@ -1038,7 +1041,7 @@ template <typename Accessor, typename LocalType, typename ServerContext, typenam
10381041
void DefaultPassField(TypeList<LocalType>, ServerContext& server_context, Fn&& fn, Args&&... args)
10391042
{
10401043
InvokeContext& invoke_context = server_context;
1041-
boost::optional<Decay<LocalType>> param;
1044+
std::optional<Decay<LocalType>> param;
10421045
const auto& params = server_context.call_context.getParams();
10431046
MaybeReadField(std::integral_constant<bool, Accessor::in>(), TypeList<LocalType>(), invoke_context,
10441047
Make<StructField, Accessor>(params), Emplace<decltype(param)>(param));
@@ -1434,9 +1437,11 @@ kj::Promise<void> serverInvoke(Server& server, CallContext& call_context, Fn fn)
14341437
server.m_connection.m_loop.log() << "IPC server send response #" << req << " " << TypeName<Results>()
14351438
<< " " << LogEscape(call_context.getResults().toString());
14361439
});
1440+
} catch (const std::exception& e) {
1441+
server.m_connection.m_loop.log() << "IPC server unhandled exception: " << e.what();
1442+
throw;
14371443
} catch (...) {
1438-
server.m_connection.m_loop.log()
1439-
<< "IPC server unhandled exception " << boost::current_exception_diagnostic_information();
1444+
server.m_connection.m_loop.log() << "IPC server unhandled exception";
14401445
throw;
14411446
}
14421447
}

0 commit comments

Comments
 (0)