13 using lock_t = std::unique_lock<mutex_t>;
15 static constexpr auto async = std::launch::async;
16 static constexpr auto deferred = std::launch::deferred;
29 stream <<
"In summation - thread ID: " << std::this_thread::get_id();
37 for(
int i=a; i < b; ++i)
48 stream <<
"In division - thread ID: " << std::this_thread::get_id();
61 stream <<
"invalid_operation: p ="
83 std::future<tis::summation_return_t>
90 catch(
const std::exception& e)
92 std::cerr << e.what() <<
'\n';
94 return tis::summation_return_t{};
105 stream <<
"Single thread summation: "
107 <<
" - elapsed: " << sw.elapsed_time() <<
tpf::endl;
109 stream <<
"Multiple thread summation: "
111 <<
" - elapsed: " << sw.elapsed_time() <<
tpf::endl;
int summation(int a, int b)
auto multiple_thread_summation(int max)
auto single_thread_summation(int max)
tpf::chrono_random::stop_watch stop_watch
static division_return_t division(double p, double q)
std::unique_lock< mutex_t > lock_t
static constexpr auto deferred
long long summation_return_t
static constexpr auto async
static summation_return_t summation(int a, int b)
Stream output operators << are implemented.
#define Tpf_ThrowDebugException(debug_message)
Throw a debug_exception with message as argument.