diff --git a/test/integration/main.cpp b/test/integration/main.cpp index 47e4cea1..2998d888 100644 --- a/test/integration/main.cpp +++ b/test/integration/main.cpp @@ -7,41 +7,70 @@ #include "nsga2.hpp" #include "nsga3.hpp" +#include "utility/rcu.hpp" +#include +#include +#include + +detail::rcu_obj number = 0; + int main() { + std::jthread reader{ [&] { + while (true) + { + std::scoped_lock _{ number }; + int& tmp = number.get(); + std::atomic_thread_fence(std::memory_order_seq_cst); + std::this_thread::sleep_for(std::chrono::milliseconds{ 2 }); + std::atomic_thread_fence(std::memory_order_seq_cst); + std::cout << tmp << "\n"; + assert(0 <= tmp && tmp <= 100); + } + } }; + + std::jthread writer1{ [&] { + while (true) number = rng::randomInt(0, 100); + } }; + + std::jthread writer2{ [&] { + while (true) number = rng::randomInt(0, 100); + } }; + + //while (true) - { - binary_sphere(); - binary_rastrigin(); - binary_rosenbrock(); - binary_schwefel(); - binary_griewank(); - binary_ackley(); - binary_levy(); - - real_sphere(); - real_rastrigin(); - real_rosenbrock(); - real_schwefel(); - real_griewank(); - real_ackley(); - real_levy(); - - perm_tsp52(); - perm_tsp76(); - perm_tsp124(); - perm_tsp152(); - perm_tsp226(); - perm_tsp299(); - perm_tsp439(); - - integer_hello(); - integer_sentence(); - - benchmark_nsga2_zdt(); - benchmark_nsga2_dtlz(); - - benchmark_nsga3_zdt(); - benchmark_nsga3_dtlz(); - } + //{ + // binary_sphere(); + // //binary_rastrigin(); + // //binary_rosenbrock(); + // //binary_schwefel(); + // //binary_griewank(); + // //binary_ackley(); + // //binary_levy(); + + // //real_sphere(); + // //real_rastrigin(); + // //real_rosenbrock(); + // //real_schwefel(); + // //real_griewank(); + // //real_ackley(); + // //real_levy(); + + // //perm_tsp52(); + // //perm_tsp76(); + // //perm_tsp124(); + // //perm_tsp152(); + // //perm_tsp226(); + // //perm_tsp299(); + // //perm_tsp439(); + + // //integer_hello(); + // //integer_sentence(); + + // //benchmark_nsga2_zdt(); + // //benchmark_nsga2_dtlz(); + + // //benchmark_nsga3_zdt(); + // //benchmark_nsga3_dtlz(); + //} } \ No newline at end of file