Skip to content

Initialize scheduler in class #20

Description

@njoye

Similar to #11 I'd like to use the scheduler inside a method of another class. Say I have Class A and Class B where A calls b.schedule() (and b is an instance of Class B), with the following code:

public: void schedule(){ Bosma::Scheduler s(12); s.every(std::chrono::milliseconds(100), [](){ // Do something in here } }

In my case, this will execute the code inside the lambda function only once. I already tried getting around this by initializing the Scheduler in-class, like this:

class ClassA(){ public: Bosma::Scheduler s(12); }

but like that compilation fails and states expected identifier before numeric constant. I also tried other variants of initialization, but since the scheduler object can't be moved or copied, these do not work either.

In the end, I just want to be able to have a modular system, where I do not expose the scheduling to the calling class / function. Is that possible, and if so: how ?

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