Skip to content

Commit

Permalink
doc: Document how to use stdexec and downgrade to upstream vcpkg version
Browse files Browse the repository at this point in the history
  • Loading branch information
Tradias committed Dec 10, 2023
1 parent 6dd10f6 commit 927e3d8
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
- 'CMakePresets.json'

env:
VCPKG_VERSION: '962e5e39f8a25f42522f51fffc574e05a3efd26b' # Jul 02, 2023
VCPKG_VERSION: '000d1bda1ffa95a73e0b40334fa4103d6f4d3d48' # Jul 02, 2023
CMAKE_ARGS: '-DCMAKE_BUILD_TYPE=Release -DVCPKG_MANIFEST_INSTALL=off -DASIO_GRPC_ENABLE_PKGCONFIG_FALLBACK=off -DCMAKE_COMPILE_WARNING_AS_ERROR=on'
CTEST_ARGS: '-T test --output-on-failure --timeout 180 --no-tests=error --parallel 25'

Expand Down
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ An [Executor, Networking TS](https://www.boost.org/doc/libs/1_81_0/doc/html/boos
* Support for generic gRPC clients and servers (aka. proxies)
* No extra codegen required, works with the vanilla gRPC C++ plugin (`grpc_cpp_plugin`)
* No-Boost version with [standalone Asio](https://github.com/chriskohlhoff/asio)
* No-Asio version with [libunifex](https://github.com/facebookexperimental/libunifex)
* No-Asio version with [libunifex](https://github.com/facebookexperimental/libunifex) or [stdexec](https://github.com/NVIDIA/stdexec)
* CMake function to generate gRPC source files: [asio_grpc_protobuf_generate](/cmake/AsioGrpcProtobufGenerator.cmake)

# Requirements

Asio-grpc is a C++17, header-only library. To install it, CMake (3.14+) is all that is needed.

To use it, [gRPC](https://grpc.io/) and either [Boost.Asio](https://www.boost.org/doc/libs/1_81_0/doc/html/boost_asio.html) (min. 1.74.0), [standalone Asio](https://github.com/chriskohlhoff/asio) (min. 1.17.0) or [libunifex](https://github.com/facebookexperimental/libunifex) must be present and linked into your application.
To use it, [gRPC](https://grpc.io/) and either [Boost.Asio](https://www.boost.org/doc/libs/1_81_0/doc/html/boost_asio.html) (min. 1.74.0), [standalone Asio](https://github.com/chriskohlhoff/asio) (min. 1.17.0), [libunifex](https://github.com/facebookexperimental/libunifex) or [stdexec](https://github.com/NVIDIA/stdexec) must be present and linked into your application.

Supported compilers are GCC 8+, Clang 10+, AppleClang 14+ and latest MSVC.

Expand Down Expand Up @@ -66,6 +66,15 @@ target_link_libraries(your_app PUBLIC asio-grpc::asio-grpc-unifex)
# Also link with the equivalents of gRPC::grpc++ and unifex::unifex
```

Or using [stdexec](https://github.com/NVIDIA/stdexec):

```cmake
add_subdirectory(/path/to/asio-grpc)
target_link_libraries(your_app PUBLIC asio-grpc::asio-grpc-stdexec)
# Also link with the equivalents of gRPC::grpc++ and STDEXEC::stdexec
```

</p>
</details>

Expand Down Expand Up @@ -105,6 +114,14 @@ find_package(asio-grpc)
target_link_libraries(your_app PUBLIC asio-grpc::asio-grpc-unifex)
```

Or using [stdexec](https://github.com/NVIDIA/stdexec):

```cmake
# Make sure CMAKE_PREFIX_PATH contains /desired/installation/directory
find_package(asio-grpc)
target_link_libraries(your_app PUBLIC asio-grpc::asio-grpc-stdexec)
```

</p>
</details>

Expand All @@ -124,7 +141,9 @@ Add [asio-grpc](https://github.com/microsoft/vcpkg/blob/master/ports/asio-grpc/v
// To use the standalone Asio backend add
// "asio",
// To use the libunifex backend add
// "libunifex"
// "libunifex",
// To use the stdexec backend add
// "stdexec"
]
}
```
Expand All @@ -139,6 +158,8 @@ target_link_libraries(your_app PUBLIC asio-grpc::asio-grpc)
#target_link_libraries(your_app PUBLIC asio-grpc::asio-grpc-standalone-asio)
# Or use the libunifex backend
#target_link_libraries(your_app PUBLIC asio-grpc::asio-grpc-unifex)
# Or use the stdexec backend
#target_link_libraries(your_app PUBLIC asio-grpc::asio-grpc-stdexec)
```

</p>
Expand Down Expand Up @@ -176,7 +197,7 @@ target_link_libraries(your_app PUBLIC asio-grpc::asio-grpc)
This type of usage is unsupported. Future versions of asio-grpc might break it without notice.

Copy the contents of the `src/` directory into your project and add it to your project's include directories. Depending on your desired backend: Boost.Asio,
standalone Asio or libunifex, set the preprocessor definitions `AGRPC_BOOST_ASIO`, `AGRPC_STANDALONE_ASIO` or `AGRPC_UNIFEX` respectively. Also make sure that
standalone Asio, libunifex or stdexec, set the preprocessor definitions `AGRPC_BOOST_ASIO`, `AGRPC_STANDALONE_ASIO`, `AGRPC_UNIFEX` or `AGRPC_STDEXEC` respectively. Also make sure that
the backend's header files and libraries can be found correctly.

</p>
Expand Down
58 changes: 0 additions & 58 deletions deps/stdexec/portfile.cmake

This file was deleted.

17 changes: 0 additions & 17 deletions deps/stdexec/vcpkg.json

This file was deleted.

3 changes: 1 addition & 2 deletions src/agrpc/detail/manual_reset_event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ class ManualResetEventOperationState
state.complete();
return;
}
auto stop_token = exec::get_stop_token(state.receiver());
if (detail::stop_requested(stop_token))
if (auto stop_token = exec::get_stop_token(state.receiver()); detail::stop_requested(stop_token))
{
exec::set_done(static_cast<Receiver&&>(state.receiver()));
return;
Expand Down
4 changes: 2 additions & 2 deletions src/agrpc/detail/register_sender_rpc_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ struct RPCHandlerOperation
struct StartReceiver
{
#ifdef AGRPC_STDEXEC
using receiver_concept = stdexec::receiver_t;
using is_receiver = void;
#endif

RPCHandlerOperation& rpc_handler_op_;
Expand Down Expand Up @@ -209,7 +209,7 @@ struct RPCHandlerOperation
struct Receiver
{
#ifdef AGRPC_STDEXEC
using receiver_concept = stdexec::receiver_t;
using is_receiver = void;
#endif

RPCHandlerOperation& op_;
Expand Down
2 changes: 1 addition & 1 deletion src/agrpc/detail/sender_of.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct SenderOf<void(Values...)>
static constexpr bool sends_done = true;

#ifdef AGRPC_STDEXEC
using sender_concept = stdexec::sender_t;
using is_sender = void;

using completion_signatures =
stdexec::completion_signatures<stdexec::set_value_t(Values...), stdexec::set_error_t(std::exception_ptr),
Expand Down
2 changes: 1 addition & 1 deletion test/cmake/subdirectory/src/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
"gtest",
"stdexec"
],
"builtin-baseline": "962e5e39f8a25f42522f51fffc574e05a3efd26b"
"builtin-baseline": "000d1bda1ffa95a73e0b40334fa4103d6f4d3d48"
}
2 changes: 1 addition & 1 deletion test/cmake/superbuild/src/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
"gtest",
"stdexec"
],
"builtin-baseline": "962e5e39f8a25f42522f51fffc574e05a3efd26b"
"builtin-baseline": "000d1bda1ffa95a73e0b40334fa4103d6f4d3d48"
}
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
"gtest",
"stdexec"
],
"builtin-baseline": "962e5e39f8a25f42522f51fffc574e05a3efd26b"
"builtin-baseline": "000d1bda1ffa95a73e0b40334fa4103d6f4d3d48"
}

0 comments on commit 927e3d8

Please sign in to comment.