18 std::vector<element_t> v(
count);
23 auto generator = tpf::chrono_random::random_generator<element_t>(0,
count);
26 for(
size_t i = 0; i <
count; ++i)
32 using lock_type = std::lock_guard<std::mutex>;
34 std::set<std::string> threads_set;
36 std::for_each(std::execution::par_unseq, v.begin(), v.end(),
37 [lambda_init =
int{}, &
mutex, &threads_set](
auto&& e)
44 os <<
"Thread Id = " << std::this_thread::get_id()
45 <<
"\t &lambda_init: " << &lambda_init;
51 lock_type lock(mutex);
53 threads_set.insert( os.str() );
58 std::cout << os.str() << std::endl;
63 stream <<
"\n Number of threads used: " << threads_set.size() <<
endl;
65 stream <<
"Threads Info: " << threads_set <<
endl;
73 std::vector<element_t> v(
count);
78 auto generator = tpf::chrono_random::random_generator<element_t>(0,
count);
81 for(
size_t i = 0; i <
count; ++i)
87 using lock_type = std::lock_guard<std::mutex>;
89 std::set<std::string> threads_set;
91 std::for_each(std::execution::par_unseq, v.begin(), v.end(),
92 [lambda_init =
int{}, &
mutex, &threads_set](
auto&& e)
103 os <<
"Thread Id = " << std::this_thread::get_id()
104 <<
"\t &lambda_init: " << &lambda_init
105 <<
"\t&local_int: " << &local_int;
111 lock_type lock(mutex);
113 threads_set.insert( os.str() );
118 std::cout << os.str() << std::endl;
123 stream <<
"\n Number of threads used: " << threads_set.size() <<
endl;
125 stream <<
"Threads Info: " << threads_set <<
endl;
139 std::set<std::string> &threads_set;
142 using lock_type = std::lock_guard<std::mutex>;
147 lock_type lock(
mutex);
154 lock_type lock(
mutex);
162 lock_type lock(
mutex);
167 template<
typename Type>
170 std::stringstream os;
179 os <<
"Thread Id = " << std::this_thread::get_id()
180 <<
"\t &lambda_init: " << &lambda_init
181 <<
"\t&local_int: " << &local_int;
187 lock_type lock(
mutex);
189 threads_set.insert( os.str() );
208 std::vector<element_t> v(
count);
213 auto generator = tpf::chrono_random::random_generator<element_t>(0,
count);
216 for(
size_t i = 0; i <
count; ++i)
222 using lock_type = std::lock_guard<std::mutex>;
224 std::set<std::string> threads_set;
226 std::for_each(std::execution::par_unseq, v.begin(), v.end(),
functor{threads_set});
229 stream <<
"\n Number of threads used: " << threads_set.size() <<
endl;
230 stream <<
"Threads Info: " << threads_set <<
endl;
void test_threads_in_parallel_algorithm()
void test_threads_in_parallel_algorithm_for_locals()
void test_threads_in_parallel_algorithm_with_functor()
functor(std::set< std::string > &threads)
void operator()(Type &&e) const
functor(const functor &rhs)
Stream output operators << are implemented.