Lines Matching refs:thread
53 thread_t* thread; member
86 start.thread = ret; in thread_new_sized()
109 void thread_free(thread_t* thread) { in thread_free() argument
110 if (!thread) return; in thread_free()
112 thread_stop(thread); in thread_free()
113 thread_join(thread); in thread_free()
115 fixed_queue_free(thread->work_queue, osi_free); in thread_free()
116 reactor_free(thread->reactor); in thread_free()
117 osi_free(thread); in thread_free()
120 void thread_join(thread_t* thread) { in thread_join() argument
121 CHECK(thread != NULL); in thread_join()
123 if (!std::atomic_exchange(&thread->is_joined, true)) in thread_join()
124 pthread_join(thread->pthread, NULL); in thread_join()
127 bool thread_post(thread_t* thread, thread_fn func, void* context) { in thread_post() argument
128 CHECK(thread != NULL); in thread_post()
140 fixed_queue_enqueue(thread->work_queue, item); in thread_post()
144 void thread_stop(thread_t* thread) { in thread_stop() argument
145 CHECK(thread != NULL); in thread_stop()
146 reactor_stop(thread->reactor); in thread_stop()
149 bool thread_set_priority(thread_t* thread, int priority) { in thread_set_priority() argument
150 if (!thread) return false; in thread_set_priority()
152 const int rc = setpriority(PRIO_PROCESS, thread->tid, priority); in thread_set_priority()
155 __func__, priority, thread->tid, rc); in thread_set_priority()
162 bool thread_set_rt_priority(thread_t* thread, int priority) { in thread_set_rt_priority() argument
163 if (!thread) return false; in thread_set_rt_priority()
168 const int rc = sched_setscheduler(thread->tid, SCHED_FIFO, &rt_params); in thread_set_rt_priority()
171 __func__, priority, thread->tid, strerror(errno)); in thread_set_rt_priority()
178 bool thread_is_self(const thread_t* thread) { in thread_is_self() argument
179 CHECK(thread != NULL); in thread_is_self()
180 return !!pthread_equal(pthread_self(), thread->pthread); in thread_is_self()
183 reactor_t* thread_get_reactor(const thread_t* thread) { in thread_get_reactor() argument
184 CHECK(thread != NULL); in thread_get_reactor()
185 return thread->reactor; in thread_get_reactor()
188 const char* thread_name(const thread_t* thread) { in thread_name() argument
189 CHECK(thread != NULL); in thread_name()
190 return thread->name; in thread_name()
197 thread_t* thread = start->thread; in run_thread() local
199 CHECK(thread != NULL); in run_thread()
201 if (prctl(PR_SET_NAME, (unsigned long)thread->name) == -1) { in run_thread()
207 thread->tid = gettid(); in run_thread()
209 LOG_INFO("%s: thread id %d, thread name %s started", __func__, thread->tid, in run_thread()
210 thread->name); in run_thread()
214 int fd = fixed_queue_get_dequeue_fd(thread->work_queue); in run_thread()
215 void* context = thread->work_queue; in run_thread()
218 reactor_register(thread->reactor, fd, context, work_queue_read_cb, NULL); in run_thread()
219 reactor_start(thread->reactor); in run_thread()
227 static_cast<work_item_t*>(fixed_queue_try_dequeue(thread->work_queue)); in run_thread()
228 while (item && count <= fixed_queue_capacity(thread->work_queue)) { in run_thread()
232 static_cast<work_item_t*>(fixed_queue_try_dequeue(thread->work_queue)); in run_thread()
236 if (count > fixed_queue_capacity(thread->work_queue)) in run_thread()
239 LOG_WARN("%s: thread id %d, thread name %s exited", __func__, thread->tid, in run_thread()
240 thread->name); in run_thread()