Closed 0x00002a closed 3 years ago
I'm guessing its to prevent multiple io_context's?
Nah, so far this was just out of convenience. The init-guard variable can easily be moved to become a private member instead. Technically, this is not necessary at all and we could just rely on documentation to tell the user not to attempt re-initialization.
As far as I know / can tell it's perfectly fine to have multiple io_context
s around.
The fact that you can currently not initialize both a server and a client is a side effect. I only very recently introduced the general controller
from which the server and client controllers inherit.
Currently there is a
static
guard variable in the root controllerinit
method that means anyinit
s after the first will always fail. This is an issue if one wants to have multiple servers or clients (or client + server). A use case example is having a server which sometimes needs to make requests to other sites and which creates a temp client to do it. I'm guessing its to prevent multipleio_context
's? Maybe could add a ctor orinit
argument that takes in another controller and duplicates the needed state?