Skip to content

Commit f6f46d4

Browse files
authored
Eliminate rand from our lives (#57)
Signed-off-by: jparisu <javierparis@eprosima.com>
1 parent a222ee7 commit f6f46d4

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

cpp_utils/src/cpp/thread_pool/task/TaskId.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* This file contains class TaskId implementation.
1919
*/
2020

21-
#include <random>
21+
#include <atomic>
2222

2323
#include <cpp_utils/thread_pool/task/TaskId.hpp>
2424

@@ -27,7 +27,8 @@ namespace utils {
2727

2828
TaskId new_unique_task_id()
2929
{
30-
return static_cast<TaskId>(std::rand());
30+
static std::atomic<TaskId> unique_task_id_{0};
31+
return unique_task_id_++;
3132
}
3233

3334
} /* namespace utils */

0 commit comments

Comments
 (0)