| 124 | } |
| 125 | |
| 126 | SlowLog *SlowLog_New(void) { |
| 127 | SlowLog *slowlog = rm_malloc(sizeof(SlowLog)); |
| 128 | |
| 129 | // Redis main thread + writer threads + reader threads. |
| 130 | int thread_count = ThreadPools_ThreadCount() + 1; |
| 131 | |
| 132 | slowlog->count = thread_count; |
| 133 | slowlog->locks = rm_malloc(sizeof(pthread_mutex_t) * thread_count); |
| 134 | slowlog->lookup = rm_malloc(sizeof(rax*) * thread_count); |
| 135 | slowlog->min_heap = rm_malloc(sizeof(heap_t*) * thread_count); |
| 136 | |
| 137 | for(int i = 0; i < thread_count; i++) { |
| 138 | slowlog->lookup[i] = raxNew(); |
| 139 | slowlog->min_heap[i] = Heap_new(_slowlog_elem_compare, NULL); |
| 140 | int res = pthread_mutex_init(slowlog->locks + i, NULL); |
| 141 | ASSERT(res == 0); |
| 142 | } |
| 143 | |
| 144 | return slowlog; |
| 145 | } |
| 146 | |
| 147 | void SlowLog_Add |
| 148 | ( |
no test coverage detected