Skip to content

std::shared_ptr<coro::scheduler> #448

@edwardbr

Description

@edwardbr

Hi I have been using a fork of your library for about a year. It is excellent although changing the scheduler factory to a coro::scheduler::make_unique for most use cases works unfortunately for me it breaks my code. I can move it though to an std::shared_ptr, but I need to tweak your server and client classes to make it all work.
I have a dynamic RPC library https://github.com/edwardbr/Canopy where many components need access to the same scheduler. Also there could be more than one scheduler and no one component is guaranteed to outlive another. Also I would prefer not using global static variables.

May we extend client to have an additional constructor

explicit client(std::unique_ptr<coro::scheduler>& scheduler, net::socket_address endpoint);
+    explicit client(std::shared_ptr<coro::scheduler> scheduler, net::socket_address endpoint);

And the same to the server:
```
explicit server(
std::unique_ptrcoro::scheduler& scheduler,
const net::socket_address& endpoint,
options opts = options{

        .backlog = 128,
    });
  • explicit server(
    std::shared_ptrcoro::scheduler scheduler,
    const net::socket_address& endpoint,
    options opts = options{

       .backlog = 128,
    

    });


I have your code in a submodule with LIBCORO_FEATURE_NETWORKING enabled yet I have my own separate submodule for  c-ares.  Can we have these two lines optional in your CMakeLists.txt file?  As they cause problems too:
    add_subdirectory(vendor/c-ares/c-ares)
    target_compile_options(c-ares PRIVATE -w)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions