Home | History | Annotate | Download | only in bionic

Lines Matching refs:timer

51 // end up with one of our POSIX timer threads handling it (meaning that the intended recipient
52 // doesn't). glibc uses SIGRTMIN for its POSIX timer implementation, so in the absence of any
61 // These fields are only needed for a SIGEV_THREAD timer.
67 static __kernel_timer_t to_kernel_timer_id(timer_t timer) {
68 return reinterpret_cast<PosixTimer*>(timer)->kernel_timer_id;
72 PosixTimer* timer = reinterpret_cast<PosixTimer*>(arg);
87 // This signal was sent because a timer fired, so call the callback.
88 timer->callback(timer->callback_argument);
91 free(timer);
97 static void __timer_thread_stop(PosixTimer* timer) {
98 pthread_kill(timer->callback_thread, TIMER_SIGNAL);
103 PosixTimer* timer = reinterpret_cast<PosixTimer*>(malloc(sizeof(PosixTimer)));
104 if (timer == NULL) {
108 timer->sigev_notify = (evp == NULL) ? SIGEV_SIGNAL : evp->sigev_notify;
110 // If not a SIGEV_THREAD timer, the kernel can handle it without our help.
111 if (timer->sigev_notify != SIGEV_THREAD) {
112 if (__timer_create(clock_id, evp, &timer->kernel_timer_id) == -1) {
113 free(timer);
117 *timer_id = timer;
121 // Otherwise, this must be SIGEV_THREAD timer...
122 timer->callback = evp->sigev_notify_function;
123 timer->callback_argument = evp->sigev_value;
126 if (timer->callback == NULL) {
127 free(timer);
132 // Create this timer's thread.
148 int rc = pthread_create(&timer->callback_thread, &thread_attributes, __timer_thread_start, timer);
153 free(timer);
161 se.sigev_notify_thread_id = pthread_gettid_np(timer->callback_thread);
162 if (__timer_create(clock_id, &se, &timer->kernel_timer_id) == -1) {
163 __timer_thread_stop(timer);
168 // It can't do this itself because the kernel timer isn't created until after it's running.
170 snprintf(name, sizeof(name), "POSIX interval timer %d", to_kernel_timer_id(timer));
171 pthread_setname_np(timer->callback_thread, name);
173 *timer_id = timer;
184 PosixTimer* timer = reinterpret_cast<PosixTimer*>(id);
185 if (timer->sigev_notify == SIGEV_THREAD) {
186 // Stopping the timer's thread frees the timer data when it's safe.
187 __timer_thread_stop(timer);
190 free(timer);