fsfw-from-zero/start/main.cpp

32 lines
693 B
C++
Raw Normal View History

2022-09-02 09:07:20 +02:00
#include <iostream>
2022-09-28 18:35:15 +02:00
#include <thread>
2022-09-02 09:07:20 +02:00
using namespace std;
2022-09-28 18:35:15 +02:00
class MyExecutableObject {
public:
MyExecutableObject(uint32_t delayMs): delayMs(delayMs) {}
static void executeTask(MyExecutableObject& self) {
while(true) {
self.performOperation();
this_thread::sleep_for(std::chrono::milliseconds(self.delayMs));
}
}
void performOperation() {
cout << "Hello World" << endl;
}
private:
uint32_t delayMs;
};
2022-09-02 09:07:20 +02:00
int main() {
2022-09-28 18:35:15 +02:00
MyExecutableObject myExecutableObject(1000);
std::thread thread(
MyExecutableObject::executeTask,
std::reference_wrapper(myExecutableObject));
thread.join();
return 0;
2022-09-28 14:35:09 +02:00
}