]> git.saurik.com Git - apple/libpthread.git/blobdiff - private/workqueue_private.h
libpthread-330.250.2.tar.gz
[apple/libpthread.git] / private / workqueue_private.h
index 9bbec51ac682ad1de47ea0034d6be80dc359027b..9cd0e951d6df271b6fbb472a48d552a7b3572436 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef __PTHREAD_WORKQUEUE_H__
 #define __PTHREAD_WORKQUEUE_H__
 
+#include <stdbool.h>
 #include <sys/cdefs.h>
 #include <sys/event.h>
 #include <Availability.h>
@@ -33,7 +34,7 @@
 #include <pthread/qos_private.h>
 #endif
 
-#define PTHREAD_WORKQUEUE_SPI_VERSION 20160427
+#define PTHREAD_WORKQUEUE_SPI_VERSION 20170201
 
 /* Feature checking flags, returned by _pthread_workqueue_supported()
  *
@@ -44,6 +45,7 @@
 #define WORKQ_FEATURE_FINEPRIO         0x02    // fine grained pthread workq priorities
 #define WORKQ_FEATURE_MAINTENANCE      0x10    // QOS class maintenance
 #define WORKQ_FEATURE_KEVENT        0x40    // Support for direct kevent delivery
+#define WORKQ_FEATURE_WORKLOOP      0x80    // Support for direct workloop requests
 
 /* Legacy dispatch priority bands */
 
@@ -70,109 +72,121 @@ typedef void (*pthread_workqueue_function2_t)(pthread_priority_t priority);
 #define WORKQ_KEVENT_EVENT_BUFFER_LEN 16
 typedef void (*pthread_workqueue_function_kevent_t)(void **events, int *nevents);
 
+typedef void (*pthread_workqueue_function_workloop_t)(uint64_t *workloop_id, void **events, int *nevents);
+
 // Initialises the pthread workqueue subsystem, passing the new-style callback prototype,
 // the dispatchoffset and an unused flags field.
-__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0)
+__API_AVAILABLE(macos(10.10), ios(8.0))
 int
 _pthread_workqueue_init(pthread_workqueue_function2_t func, int offset, int flags);
 
-__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0)
+__API_AVAILABLE(macos(10.11), ios(9.0))
 int
 _pthread_workqueue_init_with_kevent(pthread_workqueue_function2_t queue_func, pthread_workqueue_function_kevent_t kevent_func, int offset, int flags);
 
+__API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
+int
+_pthread_workqueue_init_with_workloop(pthread_workqueue_function2_t queue_func, pthread_workqueue_function_kevent_t kevent_func, pthread_workqueue_function_workloop_t workloop_func, int offset, int flags);
+
 // Non-zero enables kill on current thread, zero disables it.
-__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
+__API_AVAILABLE(macos(10.6), ios(3.2))
 int
 __pthread_workqueue_setkill(int);
 
 // Dispatch function to be called when new worker threads are created.
-__OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0)
+__API_AVAILABLE(macos(10.8), ios(6.0))
 int
 pthread_workqueue_setdispatch_np(pthread_workqueue_function_t worker_func);
 
 // Dispatch offset to be set in the kernel.
-__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
+__API_AVAILABLE(macos(10.9), ios(7.0))
 void
 pthread_workqueue_setdispatchoffset_np(int offset);
 
 // Request additional worker threads.
-__OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0)
+__API_AVAILABLE(macos(10.8), ios(6.0))
 int
 pthread_workqueue_addthreads_np(int queue_priority, int options, int numthreads);
 
 // Retrieve the supported pthread feature set
-__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0)
+__API_AVAILABLE(macos(10.10), ios(8.0))
 int
 _pthread_workqueue_supported(void);
 
 // Request worker threads (fine grained priority)
-__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0)
+__API_AVAILABLE(macos(10.10), ios(8.0))
 int
 _pthread_workqueue_addthreads(int numthreads, pthread_priority_t priority);
 
-__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0)
+// Should this thread return to the kernel?
+__API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
+bool
+_pthread_workqueue_should_narrow(pthread_priority_t priority);
+
+__API_AVAILABLE(macos(10.11), ios(9.0))
 int
 _pthread_workqueue_set_event_manager_priority(pthread_priority_t priority);
 
 // Apply a QoS override without allocating userspace memory
-__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
-__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
+__API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
 int
 _pthread_qos_override_start_direct(mach_port_t thread, pthread_priority_t priority, void *resource);
 
 // Drop a corresponding QoS override made above, if the resource matches
-__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
-__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
+__API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
 int
 _pthread_qos_override_end_direct(mach_port_t thread, void *resource);
 
 // Apply a QoS override without allocating userspace memory
-__OSX_DEPRECATED(10.10, 10.12, "use _pthread_qos_override_start_direct()")
-__IOS_DEPRECATED(8.0, 10.0, "use _pthread_qos_override_start_direct()")
-__TVOS_DEPRECATED(8.0, 10.0, "use _pthread_qos_override_start_direct()")
-__WATCHOS_DEPRECATED(1.0, 3.0, "use _pthread_qos_override_start_direct()")
+__API_DEPRECATED_WITH_REPLACEMENT("_pthread_qos_override_start_direct",
+               macos(10.10, 10.12), ios(8.0, 10.0), tvos(8.0, 10.0), watchos(1.0, 3.0))
 int
 _pthread_override_qos_class_start_direct(mach_port_t thread, pthread_priority_t priority);
 
 // Drop a corresponding QoS override made above.
-__OSX_DEPRECATED(10.10, 10.12, "use _pthread_qos_override_end_direct()")
-__IOS_DEPRECATED(8.0, 10.0, "use _pthread_qos_override_end_direct()")
-__TVOS_DEPRECATED(8.0, 10.0, "use _pthread_qos_override_end_direct()")
-__WATCHOS_DEPRECATED(1.0, 3.0, "use _pthread_qos_override_end_direct()")
+__API_DEPRECATED_WITH_REPLACEMENT("_pthread_qos_override_end_direct",
+               macos(10.10, 10.12), ios(8.0, 10.0), tvos(8.0, 10.0), watchos(1.0, 3.0))
 int
 _pthread_override_qos_class_end_direct(mach_port_t thread);
 
 // Apply a QoS override on a given workqueue thread.
-__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0)
+__API_AVAILABLE(macos(10.10), ios(8.0))
 int
 _pthread_workqueue_override_start_direct(mach_port_t thread, pthread_priority_t priority);
 
 // Apply a QoS override on a given workqueue thread.
-__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
-__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
+__API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
 int
 _pthread_workqueue_override_start_direct_check_owner(mach_port_t thread, pthread_priority_t priority, mach_port_t *ulock_addr);
 
 // Drop all QoS overrides on the current workqueue thread.
-__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0)
+__API_AVAILABLE(macos(10.10), ios(8.0))
 int
 _pthread_workqueue_override_reset(void);
 
 // Apply a QoS override on a given thread (can be non-workqueue as well) with a resource/queue token
-__OSX_AVAILABLE_STARTING(__MAC_10_10_2, __IPHONE_NA)
+__API_AVAILABLE(macos(10.10.2))
 int
 _pthread_workqueue_asynchronous_override_add(mach_port_t thread, pthread_priority_t priority, void *resource);
 
 // Reset overrides for the given resource for the current thread
-__OSX_AVAILABLE_STARTING(__MAC_10_10_2, __IPHONE_NA)
+__API_AVAILABLE(macos(10.10.2))
 int
 _pthread_workqueue_asynchronous_override_reset_self(void *resource);
 
 // Reset overrides for all resources for the current thread
-__OSX_AVAILABLE_STARTING(__MAC_10_10_2, __IPHONE_NA)
+__API_AVAILABLE(macos(10.10.2))
 int
 _pthread_workqueue_asynchronous_override_reset_all_self(void);
 
+__API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
+int
+_pthread_workloop_create(uint64_t workloop_id, uint64_t options, pthread_attr_t *attr);
+
+__API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
+int
+_pthread_workloop_destroy(uint64_t workloop_id);
+
 __END_DECLS
 
 #endif // __PTHREAD_WORKQUEUE_H__