Skip to content

Commit

Permalink
Exception handling (#77)
Browse files Browse the repository at this point in the history
* Cleanup based on best practices and clang-tidy
* Fix data race issues by cleaning up server impl
* Added `noexcept` where feasible
* Further cleanup including additional `nodiscard`
* Optimize memory usage and speed of adapters
* Add precondition asserts for func ptrs
* Hide more internals and remove unused functions
* Eliminated unnecessary/unused internal functions
* Add exception handling to public API
* `void` functions can now fail
* Tests added to verify the correct exceptions are being used
* Add version info, update to 0.7.1
  • Loading branch information
jharmer95 authored Jan 19, 2022
1 parent 8cba8ff commit 7a83063
Show file tree
Hide file tree
Showing 290 changed files with 10,169 additions and 3,786 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ cmake_minimum_required(VERSION 3.16)

project(
"rpc.hpp"
VERSION 0.6.1
VERSION 0.7.1
DESCRIPTION "Simple RPC Header-Only Library"
LANGUAGES CXX
)
Expand Down Expand Up @@ -162,6 +162,7 @@ elseif(CXX_CLANG)
-Wno-documentation
-Wno-documentation-unknown-command
-Wno-weak-vtables
-Wno-reserved-identifier
-Wno-reserved-id-macro
-Wno-missing-braces
-Wno-covered-switch-default)
Expand Down
11 changes: 6 additions & 5 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $ cmake -B build -D BUILD_ADAPTER_BOOST_JSON=ON -D BUILD_ADAPTER_NJSON=ON -D BUI
$ cmake --install build
```

CMake version 3.12 or newer is required for this method, see below for instructions to install CMake
CMake version 3.16 or newer is required for this method, see below for instructions to install CMake
if it is not already installed.

## Building and Testing the Project
Expand All @@ -36,7 +36,7 @@ need to make sure that you can build the project and its test suite.

While `rpc.hpp` is a header-only library, the project relies on using a buildsystem to
perform certain tasks.
It is therefore required that CMake (version 3.12 or newer) is installed on your machine and
It is therefore required that CMake (version 3.16 or newer) is installed on your machine and
available on your `$PATH` to build the project.

Additionally, `rpc.hpp` requires at least one C++ compiler that fully supports C++17 or newer:
Expand Down Expand Up @@ -209,16 +209,16 @@ $ mkdir build
3. Configure the project

```shell
$ cmake -B build -G Ninja -D BUILD_ADAPTER_BOOST_JSON=ON -D BUILD_ADAPTER_NJSON=ON -D BUILD_ADAPTER_RAPIDJSON=ON -D BUILD_TESTING=ON
$ cmake -B build -G Ninja -D BUILD_ADAPTER_BITSERY -D BUILD_ADAPTER_BOOST_JSON=ON -D BUILD_ADAPTER_NJSON=ON -D BUILD_ADAPTER_RAPIDJSON=ON -D BUILD_TESTING=ON
```

NOTE: The above command can be altered based on your needs:

- In this example, the "Ninja" generator is used as it is fast, but `-G Ninja` may be omitted to
use the system default make system
- With this example, all three adapters are to be built. By omitting one or more, they will not be
- With this example, all adapters are to be built. By omitting one or more, they will not be
built (example: `-D BUILD_ADAPTER_BOOST_JSON=ON` could be omitted or set to `=OFF`)
- `BUILD_ADAPTER_NJSON` is required for testing
- **NOTE:** `BUILD_ADAPTER_NJSON` is required for testing
- If using Conan to auto-install dependencies, make sure to set its option (add `-D DEPENDS_CONAN=ON`)
- If using vcpkg to manage dependencies, make sure to set its option (add `-D DEPENDS_VCPKG=ON`)
- You may also need to provide CMake with a vcpkg toolchain file:
Expand All @@ -235,6 +235,7 @@ $ cmake --build build

| Option | Description |
|--|--|
| `BUILD_ADAPTER_BITSERY` | Build the adapter for Bitsery |
| `BUILD_ADAPTER_BOOST_JSON` | Build the adapter for Boost.JSON |
| `BUILD_ADAPTER_NJSON` | Build the adapter for nlohmann/json |
| `BUILD_ADAPTER_RAPIDJSON` | Build the adapter for rapidjson |
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ server.cpp

```C++
#define RPC_HPP_SERVER_IMPL
#define RPC_HPP_ENABLE_NJSON

#include <rpc_adapters/rpc_njson.hpp>
#include <rpc_dispatch_helper.hpp>
Expand Down Expand Up @@ -101,7 +100,6 @@ client.cpp
```C++
#define RPC_HPP_CLIENT_IMPL
#define RPC_HPP_ENABLE_NJSON
#include <rpc_adapters/rpc_njson.hpp>
Expand All @@ -126,6 +124,11 @@ private:
// Send mesg to server...
}
void send(std::string&& mesg) override
{
// Send mesg to server...
}
std::string receive() override
{
// Get message back from server...
Expand Down
1 change: 1 addition & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ endif()
add_executable(rpc_benchmark benchmark.cpp)
target_include_directories(rpc_benchmark PRIVATE ../tests)
target_link_libraries(rpc_benchmark PRIVATE rpc_hpp catch2_lib asio_lib)
target_precompile_headers(rpc_benchmark PRIVATE pch.hpp)

if(${BUILD_ADAPTER_BITSERY})
target_link_libraries(rpc_benchmark PRIVATE bitsery_adapter)
Expand Down
Loading

0 comments on commit 7a83063

Please sign in to comment.