+#ifdef KERNEL_PRIVATE
+/*!
+ * @function thread_call_allocate_with_qos
+ * @abstract Allocate a thread call to execute with a specified QoS.
+ * @discussion Identical to thread_call_allocate_with_options, except it uses the QoS namespace.
+ * Private interface for pthread kext.
+ * @param func Callback to invoke when thread call is scheduled.
+ * @param param0 First argument to pass to callback.
+ * @param qos_tier QoS tier to execute callback at (as in THREAD_QOS_POLICY)
+ * @param options flags from thread_call_options_t to influence the thread call behavior
+ * @result Thread call which can be passed to thread_call_enter variants.
+ */
+extern thread_call_t
+thread_call_allocate_with_qos(thread_call_func_t func,
+ thread_call_param_t param0,
+ int qos_tier,
+ thread_call_options_t options);
+
+/*!
+ * @function thread_call_wait_once
+ * @abstract Wait for a THREAD_CALL_OPTIONS_ONCE call to finish executing if it is executing
+ * @discussion Only works on THREAD_CALL_OPTIONS_ONCE calls
+ * @param call The thread call to wait for
+ * @result True if it waited, false if it did not wait
+ */
+extern boolean_t
+thread_call_wait_once(thread_call_t call);
+#endif /* KERNEL_PRIVATE */
+
+/*!
+ * @function thread_call_free
+ * @abstract Release a thread call.
+ * @discussion Should only be used on thread calls allocated with thread_call_allocate
+ * or thread_call_allocate_with_priority. Once thread_call_free has been called,
+ * no other operations may be performed on a thread call. If the thread call is
+ * currently pending, thread_call_free will return FALSE and will have no effect.
+ * Calling thread_call_free from a thread call's own callback is safe; the work
+ * item is not considering "pending" at that point.
+ * @result TRUE if the thread call has been successfully released, else FALSE.
+ * @param call The thread call to release.
+ */
+extern boolean_t thread_call_free(
+ thread_call_t call);
+
+/*!
+ * @function thread_call_isactive
+ * @abstract Determine whether a thread call is pending or currently executing.
+ * @param call Thread call to examine.
+ * @result TRUE if the thread call is either scheduled for execution (immediately
+ * or at some point in the future) or is currently executing.
+ */
+boolean_t thread_call_isactive(
+ thread_call_t call);
+__END_DECLS
+
+#ifdef MACH_KERNEL_PRIVATE
+
+#include <kern/queue.h>
+#include <kern/priority_queue.h>
+
+__enum_closed_decl(thread_call_index_t, uint16_t, {
+ THREAD_CALL_INDEX_HIGH = 0,
+ THREAD_CALL_INDEX_KERNEL = 1,
+ THREAD_CALL_INDEX_USER = 2,
+ THREAD_CALL_INDEX_LOW = 3,
+ THREAD_CALL_INDEX_KERNEL_HIGH = 4,
+ THREAD_CALL_INDEX_QOS_UI = 5,
+ THREAD_CALL_INDEX_QOS_IN = 6,
+ THREAD_CALL_INDEX_QOS_UT = 7,
+ THREAD_CALL_INDEX_MAX = 8, /* count of thread call indexes */
+});
+
+__options_closed_decl(thread_call_flags_t, uint16_t, {
+ THREAD_CALL_ALLOC = 0x0001, /* memory owned by thread_call.c */
+ THREAD_CALL_WAIT = 0x0002, /* thread waiting for call to finish running */
+ THREAD_CALL_DELAYED = 0x0004, /* deadline based */
+ THREAD_CALL_RUNNING = 0x0008, /* currently executing on a thread */
+ THREAD_CALL_SIGNAL = 0x0010, /* call from timer interrupt instead of thread */
+ THREAD_CALL_ONCE = 0x0020, /* pend the enqueue if re-armed while running */
+ THREAD_CALL_RESCHEDULE = 0x0040, /* enqueue is pending due to re-arm while running */
+ THREAD_CALL_RATELIMITED = 0x0080, /* timer doesn't fire until slop+deadline */
+ THREAD_CALL_FLAG_CONTINUOUS = 0x0100, /* deadline is in continuous time */
+});