Lines Matching refs:ts

96 static thread_slot_t ts[MAX_THREAD];  variable
137 if (!ts[i].used) { in alloc_thread_slot()
138 ts[i].used = 1; in alloc_thread_slot()
148 ts[h].used = 0; in free_thread_slot()
158 ts[h].cmd_fdr = ts[h].cmd_fdw = -1; in btsock_thread_init()
159 ts[h].used = 0; in btsock_thread_init()
160 ts[h].thread_id = std::nullopt; in btsock_thread_init()
161 ts[h].poll_count = 0; in btsock_thread_init()
162 ts[h].callback = NULL; in btsock_thread_init()
163 ts[h].cmd_callback = NULL; in btsock_thread_init()
181 ts[h].thread_id = thread; in btsock_thread_create()
182 ts[h].callback = callback; in btsock_thread_create()
183 ts[h].cmd_callback = cmd_callback; in btsock_thread_create()
190 asrt(ts[h].cmd_fdr == -1 && ts[h].cmd_fdw == -1); in init_cmd_fd()
191 if (socketpair(AF_UNIX, SOCK_STREAM, 0, &ts[h].cmd_fdr) < 0) { in init_cmd_fd()
196 add_poll(h, ts[h].cmd_fdr, 0, SOCK_THREAD_FD_RD, 0); in init_cmd_fd()
199 if (ts[h].cmd_fdr != -1) { in close_cmd_fd()
200 close(ts[h].cmd_fdr); in close_cmd_fd()
201 ts[h].cmd_fdr = -1; in close_cmd_fd()
203 if (ts[h].cmd_fdw != -1) { in close_cmd_fd()
204 close(ts[h].cmd_fdw); in close_cmd_fd()
205 ts[h].cmd_fdw = -1; in close_cmd_fd()
220 if (ts[h].cmd_fdw == -1) { in btsock_thread_add_fd()
227 if (ts[h].thread_id.value() == pthread_self()) { in btsock_thread_add_fd()
239 OSI_NO_INTR(ret = send(ts[h].cmd_fdw, &cmd, sizeof(cmd), 0)); in btsock_thread_add_fd()
257 OSI_NO_INTR(ret = send(ts[thread_handle].cmd_fdw, &cmd, sizeof(cmd), 0)); in btsock_thread_remove_fd_and_close()
268 if (ts[h].cmd_fdw == -1) { in btsock_thread_post_cmd()
290 OSI_NO_INTR(ret = send(ts[h].cmd_fdw, cmd_send, size_send, 0)); in btsock_thread_post_cmd()
299 if (ts[h].cmd_fdw == -1) { in btsock_thread_wakeup()
306 OSI_NO_INTR(ret = send(ts[h].cmd_fdw, &cmd, sizeof(cmd), 0)); in btsock_thread_wakeup()
315 if (ts[h].cmd_fdw == -1) { in btsock_thread_exit()
322 OSI_NO_INTR(ret = send(ts[h].cmd_fdw, &cmd, sizeof(cmd), 0)); in btsock_thread_exit()
325 if (ts[h].thread_id != std::nullopt) { in btsock_thread_exit()
326 pthread_join(ts[h].thread_id.value(), 0); in btsock_thread_exit()
327 ts[h].thread_id = std::nullopt; in btsock_thread_exit()
336 ts[h].poll_count = 0; in init_poll()
337 ts[h].thread_id = std::nullopt; in init_poll()
338 ts[h].callback = NULL; in init_poll()
339 ts[h].cmd_callback = NULL; in init_poll()
341 ts[h].ps[i].pfd.fd = -1; in init_poll()
342 ts[h].psi[i] = -1; in init_poll()
372 poll_slot_t* ps = ts[h].ps; in add_poll()
376 asrt(ts[h].poll_count < MAX_POLL); in add_poll()
384 asrt(ts[h].poll_count < MAX_POLL); in add_poll()
386 ++ts[h].poll_count; in add_poll()
394 --ts[h].poll_count; in remove_poll()
406 int fd = ts[h].cmd_fdr; in process_cmd_sock()
421 poll_slot_t* poll_slot = &ts[h].ps[i]; in process_cmd_sock()
432 asrt(ts[h].cmd_callback); in process_cmd_sock()
433 if (ts[h].cmd_callback) in process_cmd_sock()
434 ts[h].cmd_callback(fd, cmd.type, cmd.flags, cmd.user_id); in process_cmd_sock()
446 asrt(count <= ts[h].poll_count); in process_data_sock()
448 for (i = 1; i < ts[h].poll_count; i++) { in process_data_sock()
450 int ps_i = ts[h].psi[i]; in process_data_sock()
451 asrt(pfds[i].fd == ts[h].ps[ps_i].pfd.fd); in process_data_sock()
452 uint32_t user_id = ts[h].ps[ps_i].user_id; in process_data_sock()
453 int type = ts[h].ps[ps_i].type; in process_data_sock()
464 remove_poll(h, &ts[h].ps[ps_i], ts[h].ps[ps_i].flags); in process_data_sock()
466 remove_poll(h, &ts[h].ps[ps_i], in process_data_sock()
468 if (flags) ts[h].callback(pfds[i].fd, type, flags, user_id); in process_data_sock()
477 asrt(ts[h].poll_count <= MAX_POLL); in prepare_poll_fds()
478 memset(pfds, 0, sizeof(pfds[0]) * ts[h].poll_count); in prepare_poll_fds()
479 while (count < ts[h].poll_count) { in prepare_poll_fds()
484 ps_i, MAX_POLL, count, ts[h].poll_count); in prepare_poll_fds()
487 if (ts[h].ps[ps_i].pfd.fd >= 0) { in prepare_poll_fds()
488 pfds[pfd_i] = ts[h].ps[ps_i].pfd; in prepare_poll_fds()
489 ts[h].psi[pfd_i] = ps_i; in prepare_poll_fds()
503 OSI_NO_INTR(ret = poll(pfds, ts[h].poll_count, -1)); in sock_poll_thread()
513 asrt(pfds[0].fd == ts[h].cmd_fdr); in sock_poll_thread()