void produsers_func() { srand(magic_number); int rand_number; for (size_t i = 0; i < 100; i++) { rand_number = 0 + rand() % 1000; try { my_queue.enqueue(rand_number); } catch (std::exception & e) { std::cout << e.what() << std::endl; } } //to stop all threads for (size_t i = 0; i < threads_number; i++) { try { my_queue.enqueue(stop_flag); } catch (std::exception & e) { std::cout << e.what() << std::endl; } } my_queue.shutdown(); std::cout << "producer has finished his work\n"; }
void produce(thread_safe_queue<int>& tasks){ for (int i = 1; i < 5600; i++) { tasks.enqueue(i); } tasks.shutdown(); }