Lines Matching refs:thread
52 thread_t* thread; member
85 start.thread = ret; in thread_new_sized()
108 void thread_free(thread_t* thread) { in thread_free() argument
109 if (!thread) return; in thread_free()
111 thread_stop(thread); in thread_free()
112 thread_join(thread); in thread_free()
114 fixed_queue_free(thread->work_queue, osi_free); in thread_free()
115 reactor_free(thread->reactor); in thread_free()
116 osi_free(thread); in thread_free()
119 void thread_join(thread_t* thread) { in thread_join() argument
120 CHECK(thread != NULL); in thread_join()
122 if (!std::atomic_exchange(&thread->is_joined, true)) in thread_join()
123 pthread_join(thread->pthread, NULL); in thread_join()
126 bool thread_post(thread_t* thread, thread_fn func, void* context) { in thread_post() argument
127 CHECK(thread != NULL); in thread_post()
139 fixed_queue_enqueue(thread->work_queue, item); in thread_post()
143 void thread_stop(thread_t* thread) { in thread_stop() argument
144 CHECK(thread != NULL); in thread_stop()
145 reactor_stop(thread->reactor); in thread_stop()
148 bool thread_set_priority(thread_t* thread, int priority) { in thread_set_priority() argument
149 if (!thread) return false; in thread_set_priority()
151 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()
172 __func__, priority, thread->tid, strerror(errno)); in thread_set_rt_priority()
179 bool thread_is_self(const thread_t* thread) { in thread_is_self() argument
180 CHECK(thread != NULL); in thread_is_self()
181 return !!pthread_equal(pthread_self(), thread->pthread); in thread_is_self()
184 reactor_t* thread_get_reactor(const thread_t* thread) { in thread_get_reactor() argument
185 CHECK(thread != NULL); in thread_get_reactor()
186 return thread->reactor; in thread_get_reactor()
189 const char* thread_name(const thread_t* thread) { in thread_name() argument
190 CHECK(thread != NULL); in thread_name()
191 return thread->name; in thread_name()
198 thread_t* thread = start->thread; in run_thread() local
200 CHECK(thread != NULL); in run_thread()
202 if (prctl(PR_SET_NAME, (unsigned long)thread->name) == -1) { in run_thread()
209 thread->tid = gettid(); in run_thread()
212 thread->tid, thread->name); in run_thread()
216 int fd = fixed_queue_get_dequeue_fd(thread->work_queue); in run_thread()
217 void* context = thread->work_queue; in run_thread()
220 reactor_register(thread->reactor, fd, context, work_queue_read_cb, NULL); in run_thread()
221 reactor_start(thread->reactor); in run_thread()
229 static_cast<work_item_t*>(fixed_queue_try_dequeue(thread->work_queue)); in run_thread()
230 while (item && count <= fixed_queue_capacity(thread->work_queue)) { in run_thread()
234 static_cast<work_item_t*>(fixed_queue_try_dequeue(thread->work_queue)); in run_thread()
238 if (count > fixed_queue_capacity(thread->work_queue)) in run_thread()
242 thread->tid, thread->name); in run_thread()