Skip to content

Commit

Permalink
Homework
Browse files Browse the repository at this point in the history
  • Loading branch information
Iosis713 committed Nov 11, 2024
1 parent 0c3d0bf commit 2aa53da
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
6 changes: 3 additions & 3 deletions homework/schedule/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

include_directories(.)

add_executable(${PROJECT_NAME} main.cpp)
add_executable(${PROJECT_NAME}-ut tests/catch/catch_amalgamated.cpp tests/catch/catch_main.cpp tests/tests.cpp)
add_executable(${PROJECT_NAME}-ut-bonus tests/catch/catch_amalgamated.cpp tests/catch/catch_main.cpp tests/tests-bonus.cpp)
add_executable(${PROJECT_NAME} main.cpp schedule.cpp)
add_executable(${PROJECT_NAME}-ut tests/catch/catch_amalgamated.cpp tests/catch/catch_main.cpp tests/tests.cpp schedule.cpp)
add_executable(${PROJECT_NAME}-ut-bonus tests/catch/catch_amalgamated.cpp tests/catch/catch_main.cpp tests/tests-bonus.cpp schedule.cpp)

target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror -Wpedantic)
target_compile_options(${PROJECT_NAME}-ut PRIVATE -Wall -Wextra -Werror -Wpedantic)
Expand Down
22 changes: 22 additions & 0 deletions homework/schedule/schedule.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "schedule.hpp"

void schedule(std::function<void()> func, std::chrono::seconds duration)
{
std::this_thread::sleep_for(duration);
func();
}


void schedule(std::function<void(int)> func, std::chrono::seconds duration, int integer)
{
std::this_thread::sleep_for(duration);
func(integer);
}


void schedule(std::function<void(std::string, double)> func, std::chrono::seconds duration, std::string str, double d)
{
std::this_thread::sleep_for(duration);
func(str, d);
}

16 changes: 16 additions & 0 deletions homework/schedule/schedule.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
#ifndef SCHEDULE
#define SCHEDULE

#include <chrono>
#include <iostream>
#include <functional>
#include <thread>
#include <string>

void schedule(std::function<void()> func, std::chrono::seconds duration);
void schedule(std::function<void(int)> func, std::chrono::seconds duration, int integer);
void schedule(std::function<void(std::string, double)> func, std::chrono::seconds duration, std::string str, double d);

#endif

0 comments on commit 2aa53da

Please sign in to comment.