Refactor Packet I/O
This commit is contained in:
@@ -63,13 +63,13 @@ uint64_t id_generator_alloc()
|
||||
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME, &ts); // must be realtime
|
||||
uint64_t thread_index = stellar_get_current_thread_index();
|
||||
uint64_t thr_idx = stellar_get_current_thread_index();
|
||||
|
||||
uint64_t global_id = 0;
|
||||
uint64_t id_per_thread = (global_id_generator.thread_volatile[thread_index]++) % MAX_ID_PER_THREAD;
|
||||
uint64_t id_per_thread = (global_id_generator.thread_volatile[thr_idx]++) % MAX_ID_PER_THREAD;
|
||||
uint64_t id_base_time = ts.tv_sec % MAX_ID_BASE_TIME;
|
||||
global_id = (global_id_generator.device_id << 51) |
|
||||
(thread_index << 43) |
|
||||
(thr_idx << 43) |
|
||||
(id_base_time << 15) |
|
||||
(id_per_thread);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user