Lines Matching refs:call

96 static __inline__ void		_internal_call_release(thread_call_t call);
97 static __inline__ boolean_t _pending_call_enqueue(thread_call_t call, thread_call_group_t group);
98 static __inline__ boolean_t _delayed_call_enqueue(thread_call_t call, thread_call_group_t group, uint64_t deadline);
99 static __inline__ boolean_t _call_dequeue(thread_call_t call, thread_call_group_t group);
101 static __inline__ void _set_delayed_call_timer(thread_call_t call, thread_call_group_t group);
111 static void thread_call_wait_locked(thread_call_t call);
222 thread_call_t call)
224 thread_call_priority_t pri = call->tc_pri;
261 * thread call groups.
297 thread_call_t call;
330 call = internal_call_storage;
331 call < &internal_call_storage[INTERNAL_CALL_COUNT];
332 call++) {
334 enqueue_tail(&thread_call_internal_queue, qe(call));
350 thread_call_t call,
354 bzero(call, sizeof(*call));
355 call_entry_setup((call_entry_t)call, func, param0);
356 call->tc_pri = THREAD_CALL_PRIORITY_HIGH; /* Default priority */
369 thread_call_t call;
374 call = TC(dequeue_head(&thread_call_internal_queue));
376 return (call);
389 thread_call_t call)
391 if ( call >= internal_call_storage &&
392 call < &internal_call_storage[INTERNAL_CALL_COUNT] )
393 enqueue_head(&thread_call_internal_queue, qe(call));
409 thread_call_t call,
414 old_queue = call_entry_enqueue_tail(CE(call), &group->pending_queue);
417 call->tc_submit_count++;
441 thread_call_t call,
447 old_queue = call_entry_enqueue_deadline(CE(call), &group->delayed_queue, deadline);
452 call->tc_submit_count++;
468 thread_call_t call,
473 old_queue = call_entry_dequeue(CE(call));
476 call->tc_finish_count++;
494 thread_call_t call,
497 timer_call_enter(&group->delayed_timer, call->tc_call.deadline, 0);
518 thread_call_t call;
521 call = TC(queue_first(&group->pending_queue));
523 while (!queue_end(&group->pending_queue, qe(call))) {
524 if (call->tc_call.func == func &&
525 call->tc_call.param0 == param0) {
526 thread_call_t next = TC(queue_next(qe(call)));
528 _call_dequeue(call, group);
530 _internal_call_release(call);
536 call = next;
539 call = TC(queue_next(qe(call)));
563 thread_call_t call;
566 call = TC(queue_first(&group->delayed_queue));
568 while (!queue_end(&group->delayed_queue, qe(call))) {
569 if (call->tc_call.func == func &&
570 call->tc_call.param0 == param0) {
571 thread_call_t next = TC(queue_next(qe(call)));
573 _call_dequeue(call, group);
575 _internal_call_release(call);
581 call = next;
584 call = TC(queue_next(qe(call)));
606 thread_call_t call;
613 call = TC(queue_first(&group->pending_queue));
615 while (unique_call && !queue_end(&group->pending_queue, qe(call))) {
616 if (call->tc_call.func == func && call->tc_call.param0 == param) {
620 call = TC(queue_next(qe(call)));
623 if (!unique_call || queue_end(&group->pending_queue, qe(call))) {
624 call = _internal_call_allocate();
625 call->tc_call.func = func;
626 call->tc_call.param0 = param;
627 call->tc_call.param1 = NULL;
629 _pending_call_enqueue(call, group);
650 thread_call_t call;
657 call = _internal_call_allocate();
658 call->tc_call.func = func;
659 call->tc_call.param0 = param;
660 call->tc_call.param1 = 0;
662 _delayed_call_enqueue(call, group, deadline);
664 if (queue_first(&group->delayed_queue) == qe(call))
665 _set_delayed_call_timer(call, group);
709 * Allocate a thread call with a given priority. Importances
720 thread_call_t call;
726 call = thread_call_allocate(func, param0);
727 call->tc_pri = pri;
729 return call;
742 thread_call_t call = zalloc(thread_call_zone);
744 thread_call_setup(call, func, param0);
745 call->tc_refs = 1;
746 call->tc_flags = THREAD_CALL_ALLOC;
748 return (call);
760 thread_call_t call)
768 if (call->tc_call.queue != NULL) {
775 refs = --call->tc_refs;
784 zfree(thread_call_zone, call);
795 * Returns TRUE if the call was
800 thread_call_t call)
806 group = thread_call_get_group(call);
811 if (call->tc_call.queue != &group->pending_queue) {
812 result = _pending_call_enqueue(call, group);
815 call->tc_call.param1 = 0;
825 thread_call_t call,
832 group = thread_call_get_group(call);
837 if (call->tc_call.queue != &group->pending_queue) {
838 result = _pending_call_enqueue(call, group);
841 call->tc_call.param1 = param1;
855 * Returns TRUE if the call was
860 thread_call_t call,
867 group = thread_call_get_group(call);
872 result = _delayed_call_enqueue(call, group, deadline);
874 if (queue_first(&group->delayed_queue) == qe(call))
875 _set_delayed_call_timer(call, group);
877 call->tc_call.param1 = 0;
887 thread_call_t call,
896 group = thread_call_get_group(call);
902 result = _delayed_call_enqueue(call, group, deadline);
904 if (queue_first(&group->delayed_queue) == qe(call))
905 _set_delayed_call_timer(call, group);
907 call->tc_call.param1 = param1;
909 call->ttd = (deadline > abstime) ? (deadline - abstime) : 0;
911 DTRACE_TMR4(thread_callout__create, thread_call_func_t, call->tc_call.func, 0, (call->ttd >> 32), (unsigned) (call->ttd & 0xFFFFFFFF));
924 * Returns TRUE if the call was
929 thread_call_t call)
935 group = thread_call_get_group(call);
940 result = _call_dequeue(call, group);
945 DTRACE_TMR4(thread_callout__cancel, thread_call_func_t, call->tc_call.func, 0, (call->ttd >> 32), (unsigned) (call->ttd & 0xFFFFFFFF));
952 * Cancel a thread call. If it cannot be cancelled (i.e.
954 * to finish. Note that if clients re-submit this thread call,
957 * to the call to thread_call_cancel_wait will have finished.
961 thread_call_t call)
966 if ((call->tc_flags & THREAD_CALL_ALLOC) == 0) {
967 panic("%s: Can't wait on thread call whose storage I don't own.", __FUNCTION__);
970 group = thread_call_get_group(call);
975 result = _call_dequeue(call, group);
977 thread_call_wait_locked(call);
992 * Returns TRUE if the call is
999 thread_call_t call,
1006 group = thread_call_get_group(call);
1011 if (call->tc_call.queue == &group->delayed_queue) {
1013 *deadline = call->tc_call.deadline;
1028 * Wake a call thread to service
1029 * pending call entries. May wake
1031 * create additional call threads.
1067 * thread call group.
1103 thread_call_finish(thread_call_t call)
1107 call->tc_finish_count++;
1108 call->tc_refs--;
1110 if ((call->tc_flags & THREAD_CALL_WAIT) != 0) {
1112 call->tc_flags &= ~THREAD_CALL_WAIT;
1115 * Dropping lock here because the sched call for the
1120 thread_wakeup((event_t)call);
1124 if (call->tc_refs == 0) {
1126 panic("Someone waiting on a thread call that is scheduled for free: %p\n", call->tc_call.func);
1131 zfree(thread_call_zone, call);
1168 thread_call_t call;
1172 call = TC(dequeue_head(&group->pending_queue));
1175 func = call->tc_call.func;
1176 param0 = call->tc_call.param0;
1177 param1 = call->tc_call.param1;
1179 call->tc_call.queue = NULL;
1181 _internal_call_release(call);
1187 if ((call->tc_flags & THREAD_CALL_ALLOC) != 0) {
1189 call->tc_refs++; /* Delay free until we're done */
1213 thread_call_finish(call);
1357 thread_call_t call;
1365 call = TC(queue_first(&group->delayed_queue));
1367 while (!queue_end(&group->delayed_queue, qe(call))) {
1368 if (call->tc_call.deadline <= timestamp) {
1369 _pending_call_enqueue(call, group);
1374 call = TC(queue_first(&group->delayed_queue));
1377 if (!queue_end(&group->delayed_queue, qe(call)))
1378 _set_delayed_call_timer(call, group);
1435 * Wait for all requested invocations of a thread call prior to now
1441 thread_call_wait_locked(thread_call_t call)
1446 assert(call->tc_flags & THREAD_CALL_ALLOC);
1448 submit_count = call->tc_submit_count;
1450 while (call->tc_finish_count < submit_count) {
1451 call->tc_flags |= THREAD_CALL_WAIT;
1453 res = assert_wait(call, THREAD_UNINT);
1472 * Determine whether a thread call is either on a queue or
1476 thread_call_isactive(thread_call_t call)
1481 active = (call->tc_submit_count > call->tc_finish_count);