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()
154 __func__, priority, thread->tid, rc); in thread_set_priority()
161 bool thread_set_rt_priority(thread_t* thread, int priority) { in thread_set_rt_priority() argument
162 if (!thread) return false; in thread_set_rt_priority()
167 const int rc = sched_setscheduler(thread->tid, SCHED_FIFO, &rt_params); in thread_set_rt_priority()
170 __func__, priority, thread->tid, strerror(errno)); in thread_set_rt_priority()
177 bool thread_is_self(const thread_t* thread) { in thread_is_self() argument
178 CHECK(thread != NULL); in thread_is_self()
179 return !!pthread_equal(pthread_self(), thread->pthread); in thread_is_self()
182 reactor_t* thread_get_reactor(const thread_t* thread) { in thread_get_reactor() argument
183 CHECK(thread != NULL); in thread_get_reactor()
184 return thread->reactor; in thread_get_reactor()
187 const char* thread_name(const thread_t* thread) { in thread_name() argument
188 CHECK(thread != NULL); in thread_name()
189 return thread->name; in thread_name()
196 thread_t* thread = start->thread; in run_thread() local
198 CHECK(thread != NULL); in run_thread()
200 if (prctl(PR_SET_NAME, (unsigned long)thread->name) == -1) { in run_thread()
206 thread->tid = gettid(); in run_thread()
208 LOG_INFO("%s: thread id %d, thread name %s started", __func__, thread->tid, in run_thread()
209 thread->name); in run_thread()
213 int fd = fixed_queue_get_dequeue_fd(thread->work_queue); in run_thread()
214 void* context = thread->work_queue; in run_thread()
217 reactor_register(thread->reactor, fd, context, work_queue_read_cb, NULL); in run_thread()
218 reactor_start(thread->reactor); in run_thread()
226 static_cast<work_item_t*>(fixed_queue_try_dequeue(thread->work_queue)); in run_thread()
227 while (item && count <= fixed_queue_capacity(thread->work_queue)) { in run_thread()
231 static_cast<work_item_t*>(fixed_queue_try_dequeue(thread->work_queue)); in run_thread()
235 if (count > fixed_queue_capacity(thread->work_queue)) in run_thread()
238 LOG_WARN("%s: thread id %d, thread name %s exited", __func__, thread->tid, in run_thread()
239 thread->name); in run_thread()