Scheduler icon indicating copy to clipboard operation
Scheduler copied to clipboard

Initialize scheduler in class

Open njoye opened this issue 5 years ago • 0 comments

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 ?

njoye avatar Apr 11 '19 13:04 njoye