-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply update_interval as soon as it is called.
- Loading branch information
1 parent
6e06e90
commit dfac66f
Showing
10 changed files
with
136 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
**/results | ||
**/unit_tests | ||
**/profiles | ||
**/memcheck | ||
**/callgrind | ||
**/logs | ||
**/.cache | ||
**/.clangd | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <ssts/task_scheduler.hpp> | ||
#include <spdlog/spdlog.h> | ||
#include "utils/utils.hpp" | ||
|
||
int main() | ||
{ | ||
spdlog::set_pattern("[%H:%M:%S.%e] %v"); | ||
spdlog::info(ssts::version()); | ||
|
||
ssts::task_scheduler s(8); | ||
s.start(); | ||
|
||
ssts::utils::timer t; | ||
|
||
s.in("Foo"s, 2s, []{ spdlog::info("Foo"); }); | ||
s.in("Bar"s, 3s, []{ spdlog::info("Bar"); }); | ||
|
||
spdlog::info("before remove"); | ||
std::this_thread::sleep_for(2s); | ||
|
||
s.remove_task("foo"s); // Wrong task ID | ||
s.remove_task("Bar"s); | ||
|
||
spdlog::info("after remove"); | ||
std::this_thread::sleep_for(2s); | ||
|
||
spdlog::info("Task Scheduler shutdown"); | ||
s.stop(); | ||
|
||
spdlog::info("Task Scheduler finished"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
#include <ssts/task_scheduler.hpp> | ||
|
||
#include <spdlog/spdlog.h> | ||
#include "utils/utils.hpp" | ||
|
||
void t_update_interval() | ||
int main() | ||
{ | ||
ssts::utils::log_test("Update Interval"); | ||
ssts::task_scheduler s(2); | ||
spdlog::set_pattern("[%H:%M:%S.%e] %v"); | ||
spdlog::info(ssts::version()); | ||
|
||
ssts::task_scheduler s(8); | ||
s.start(); | ||
|
||
ssts::utils::timer t; | ||
|
||
s.every("Foo"s, 2s, []{ spdlog::info("Foo"); }); | ||
|
||
s.every("Bar"s, 2s, []{ spdlog::info("Bar"); }); | ||
|
||
s.every("task_id"s, 250ms, []{ std::cout << "Hi!" << std::endl; }); | ||
s.in(1ms, []{ spdlog::info("one millis!"); }); | ||
|
||
ssts::utils::log("before update"); | ||
spdlog::info("before update"); | ||
std::this_thread::sleep_for(3s); | ||
|
||
s.update_interval("task_id"s, 1s); | ||
ssts::utils::log("after update"); | ||
std::this_thread::sleep_for(4s); | ||
} | ||
s.update_interval("foo"s, 100ms); // Wrong task ID | ||
s.update_interval("Bar"s, 100ms); | ||
|
||
int main() | ||
{ | ||
ssts::utils::log(ssts::version()); | ||
spdlog::info("after update"); | ||
std::this_thread::sleep_for(2s); | ||
|
||
t_update_interval(); | ||
spdlog::info("Task Scheduler shutdown"); | ||
s.stop(); | ||
|
||
ssts::utils::log("Task Scheduler finished"); | ||
spdlog::info("Task Scheduler finished"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
cd ~/Downloads | ||
|
||
sudo apt remove --purge valgrind -y | ||
|
||
wget https://sourceware.org/pub/valgrind/valgrind-3.20.0.tar.bz2 | ||
tar xvf valgrind-3.20.0.tar.bz2 | ||
|
||
export CC=gcc-12 | ||
|
||
cd valgrind-3.20.0 | ||
./configure | ||
make | ||
sudo make install | ||
|
||
cd .. | ||
rm -r valgrind-3.20.0 | ||
rm -r valgrind-3.20.0.tar.bz2 | ||
|
||
echo "" | ||
valgrind --version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
mkdir -p callgrind | ||
|
||
valgrind --tool=callgrind \ | ||
--callgrind-out-file=callgrind/callgrind.out \ | ||
--verbose \ | ||
--log-file=callgrind/callgrind.log \ | ||
--error-exitcode=1 \ | ||
./build/Debug/examples/example_remove | ||
|
||
# --exit-on-first-error=yes \ | ||
|
||
# callgrind_annotate --auto=yes callgrind.out | ||
|
||
ret=$? | ||
echo "" | ||
echo "callgrind exit code: " $ret | ||
exit $ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
mkdir -p memcheck | ||
|
||
valgrind --tool=memcheck \ | ||
--leak-check=full \ | ||
--show-leak-kinds=all \ | ||
--track-origins=yes \ | ||
--verbose \ | ||
--xml=yes \ | ||
--xml-file=memcheck/memcheck.xml \ | ||
--log-file=memcheck/memcheck.log \ | ||
--error-exitcode=1 \ | ||
./build/Debug/examples/example_remove | ||
|
||
# --exit-on-first-error=yes \ | ||
|
||
ret=$? | ||
echo "" | ||
echo "memcheck exit code: " $ret | ||
exit $ret |