Skip to content

Commit

Permalink
Changed to template
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Markiewicz committed Jun 7, 2024
1 parent 4ac459a commit 2c27b76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
13 changes: 0 additions & 13 deletions homework/schedule/schedule.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
#include "schedule.hpp"

void schedule(std::function<void()> func, std::chrono::seconds sec) {
std::this_thread::sleep_for(sec);
func();
}
void schedule(std::function<void(int)> func, std::chrono::seconds sec, int a) {
std::this_thread::sleep_for(sec);
func(a);
}
void schedule(std::function<void(std::string, double)> func, std::chrono::seconds sec, std::string str, double a) {
std::this_thread::sleep_for(sec);
func(str, a);
}
8 changes: 5 additions & 3 deletions homework/schedule/schedule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <string>
#include <thread>

void schedule(std::function<void()> func, std::chrono::seconds sec);
void schedule(std::function<void(int)> func, std::chrono::seconds sec, int a);
void schedule(std::function<void(std::string, double)> func, std::chrono::seconds sec, std::string str, double a);
template <typename Func, typename... A>
void schedule( Func func, std::chrono::seconds sec, A... a ){
std::this_thread::sleep_for( sec );
func(a...);
}

0 comments on commit 2c27b76

Please sign in to comment.