Comment 2 for bug 1712421

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

CommandLineOption and the other "glue" classes were designed with the idea that they'd be passed to MirRunner::run_with() and exist for the lifetime of the server.

It is purely accidental that AddInitCallback (used in the example) doesn't need to exist beyond the initial call to operator().

I don't think it impossible to support your usage for this case: as you imply the wrapper callback could be curried by value. Vis:

    server.add_init_callback([&server, callback = self->callback]{ callback(server); });

But I'm not sure this can work for all these classes, or how useful it really is.

Specifically, why isn't the logic you pass to AddInitCallback invoked by the CommandLineOption? Vis:

    auto check_blacklist_option = pre_init(CommandLineOption(
        [](std::string const& blacklist_regex) { check_blacklist(blacklist_regex); },
        "blacklist", "Video blacklist regex to use", ""))};
    ...
    check_blacklist_option(*config);

AFAIC that would remove the need for usc::Blacklist - a check_blacklist() function would suffice.