| 42 | } |
| 43 | |
| 44 | void complex_operation(int id) { |
| 45 | CTRACK; |
| 46 | std::random_device rd; |
| 47 | std::mt19937 gen(rd()); |
| 48 | std::uniform_int_distribution<> dis(1, 10); |
| 49 | |
| 50 | for (int i = 0; i < 5; ++i) { |
| 51 | int random_num = dis(gen); |
| 52 | if (random_num % 2 == 0) { |
| 53 | nested_function_a(random_num); |
| 54 | } else { |
| 55 | nested_function_b(random_num); |
| 56 | } |
| 57 | |
| 58 | if (random_num == 7) { // Rare slow path |
| 59 | recursive_work(20); |
| 60 | } |
| 61 | |
| 62 | global_counter.fetch_add(1, std::memory_order_relaxed); |
| 63 | } |
| 64 | |
| 65 | { |
| 66 | std::lock_guard<std::mutex> lock(cout_mutex); |
| 67 | std::cout << "Thread " << id << " completed." << std::endl; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | int main() { |
| 72 | const int thread_count = 4; |
nothing calls this directly
no test coverage detected