init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
21
Telegram/ThirdParty/dispatch/private/CMakeLists.txt
vendored
Normal file
21
Telegram/ThirdParty/dispatch/private/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
# TODO(compnerd) ensure that benchmark.h data_private.h introduction_private.h
|
||||
# io_private.h layout_private.h mach_private.h private.h queue_private.h
|
||||
# source_private.h are included in the source tarball
|
||||
|
||||
if (INSTALL_PRIVATE_HEADERS)
|
||||
install(FILES
|
||||
benchmark.h
|
||||
data_private.h
|
||||
introspection_private.h
|
||||
io_private.h
|
||||
layout_private.h
|
||||
mach_private.h
|
||||
private.h
|
||||
queue_private.h
|
||||
source_private.h
|
||||
time_private.h
|
||||
workloop_private.h
|
||||
DESTINATION
|
||||
"${INSTALL_DISPATCH_HEADERS_DIR}")
|
||||
endif()
|
||||
89
Telegram/ThirdParty/dispatch/private/benchmark.h
vendored
Normal file
89
Telegram/ThirdParty/dispatch/private/benchmark.h
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2009 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
* IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
|
||||
* which are subject to change in future releases of Mac OS X. Any applications
|
||||
* relying on these interfaces WILL break.
|
||||
*/
|
||||
|
||||
#ifndef __DISPATCH_BENCHMARK__
|
||||
#define __DISPATCH_BENCHMARK__
|
||||
|
||||
#ifndef __DISPATCH_INDIRECT__
|
||||
#error "Please #include <dispatch/private.h> instead of this file directly."
|
||||
#include <dispatch/base.h> // for HeaderDoc
|
||||
#endif
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_BEGIN
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*!
|
||||
* @function dispatch_benchmark
|
||||
*
|
||||
* @abstract
|
||||
* Count the average number of cycles a given block takes to execute.
|
||||
*
|
||||
* @param count
|
||||
* The number of times to serially execute the given block.
|
||||
*
|
||||
* @param block
|
||||
* The block to execute.
|
||||
*
|
||||
* @result
|
||||
* The approximate number of cycles the block takes to execute.
|
||||
*
|
||||
* @discussion
|
||||
* This function is for debugging and performance analysis work. For the best
|
||||
* results, pass a high count value to dispatch_benchmark(). When benchmarking
|
||||
* concurrent code, please compare the serial version of the code against the
|
||||
* concurrent version, and compare the concurrent version on different classes
|
||||
* of hardware. Please look for inflection points with various data sets and
|
||||
* keep the following facts in mind:
|
||||
*
|
||||
* 1) Code bound by computational bandwidth may be inferred by proportional
|
||||
* changes in performance as concurrency is increased.
|
||||
* 2) Code bound by memory bandwidth may be inferred by negligible changes in
|
||||
* performance as concurrency is increased.
|
||||
* 3) Code bound by critical sections may be inferred by retrograde changes in
|
||||
* performance as concurrency is increased.
|
||||
* 3a) Intentional: locks, mutexes, and condition variables.
|
||||
* 3b) Accidental: unrelated and frequently modified data on the same
|
||||
* cache-line.
|
||||
*/
|
||||
#ifdef __BLOCKS__
|
||||
API_AVAILABLE(macos(10.6), ios(4.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW
|
||||
uint64_t
|
||||
dispatch_benchmark(size_t count, dispatch_block_t block);
|
||||
#endif
|
||||
|
||||
API_AVAILABLE(macos(10.6), ios(4.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL3 DISPATCH_NOTHROW
|
||||
uint64_t
|
||||
dispatch_benchmark_f(size_t count, void *_Nullable ctxt,
|
||||
dispatch_function_t func);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
10
Telegram/ThirdParty/dispatch/private/darwin/module.modulemap
vendored
Normal file
10
Telegram/ThirdParty/dispatch/private/darwin/module.modulemap
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
module DispatchPrivate [system] [extern_c] {
|
||||
umbrella header "private.h"
|
||||
exclude header "mach_private.h"
|
||||
export *
|
||||
}
|
||||
|
||||
module DispatchIntrospectionPrivate [system] [extern_c] {
|
||||
header "introspection_private.h"
|
||||
export *
|
||||
}
|
||||
325
Telegram/ThirdParty/dispatch/private/data_private.h
vendored
Normal file
325
Telegram/ThirdParty/dispatch/private/data_private.h
vendored
Normal file
@@ -0,0 +1,325 @@
|
||||
/*
|
||||
* Copyright (c) 2011-2013 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
* IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
|
||||
* which are subject to change in future releases of Mac OS X. Any applications
|
||||
* relying on these interfaces WILL break.
|
||||
*/
|
||||
|
||||
#ifndef __DISPATCH_DATA_PRIVATE__
|
||||
#define __DISPATCH_DATA_PRIVATE__
|
||||
|
||||
#ifndef __DISPATCH_INDIRECT__
|
||||
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
|
||||
#include <dispatch/base.h> // for HeaderDoc
|
||||
#endif
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_BEGIN
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_DATA_DESTRUCTOR_NONE
|
||||
* @discussion The destructor for dispatch data objects that require no buffer
|
||||
* memory management. This can be used to allow a data object to efficiently
|
||||
* encapsulate buffers that should not be copied or freed by the system.
|
||||
*/
|
||||
#define DISPATCH_DATA_DESTRUCTOR_NONE (_dispatch_data_destructor_none)
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
DISPATCH_DATA_DESTRUCTOR_TYPE_DECL(none);
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_DATA_DESTRUCTOR_VM_DEALLOCATE
|
||||
* @discussion The destructor for dispatch data objects that have been created
|
||||
* from buffers that require deallocation using vm_deallocate.
|
||||
*/
|
||||
#define DISPATCH_DATA_DESTRUCTOR_VM_DEALLOCATE \
|
||||
(_dispatch_data_destructor_vm_deallocate)
|
||||
API_AVAILABLE(macos(10.8), ios(6.0)) DISPATCH_LINUX_UNAVAILABLE()
|
||||
DISPATCH_DATA_DESTRUCTOR_TYPE_DECL(vm_deallocate);
|
||||
|
||||
/*!
|
||||
* @function dispatch_data_create_f
|
||||
* Creates a dispatch data object from the given contiguous buffer of memory. If
|
||||
* a non-default destructor is provided, ownership of the buffer remains with
|
||||
* the caller (i.e. the bytes will not be copied). The last release of the data
|
||||
* object will result in the invocation of the specified destructor function on
|
||||
* specified queue to free the buffer (passed as the context parameter).
|
||||
*
|
||||
* If the DISPATCH_DATA_DESTRUCTOR_FREE destructor is provided the buffer will
|
||||
* be freed via free(3) and the queue argument ignored.
|
||||
*
|
||||
* If the DISPATCH_DATA_DESTRUCTOR_DEFAULT destructor is provided, data object
|
||||
* creation will copy the buffer into internal memory managed by the system.
|
||||
*
|
||||
* @param buffer A contiguous buffer of data.
|
||||
* @param size The size of the contiguous buffer of data.
|
||||
* @param queue The queue to which the destructor should be submitted.
|
||||
* @param destructor The destructor function responsible for freeing the
|
||||
* data buffer when it is no longer needed.
|
||||
* @result A newly created dispatch data object.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT DISPATCH_NOTHROW
|
||||
dispatch_data_t
|
||||
dispatch_data_create_f(const void *buffer,
|
||||
size_t size,
|
||||
dispatch_queue_t _Nullable queue,
|
||||
dispatch_function_t _Nullable destructor);
|
||||
|
||||
/*!
|
||||
* @function dispatch_data_create_alloc
|
||||
* Creates a dispatch data object representing a newly allocated memory region
|
||||
* of the given size. If a non-NULL reference to a pointer is provided, it is
|
||||
* filled with the location of the memory region.
|
||||
*
|
||||
* It is the responsibility of the application to ensure that the data object
|
||||
* becomes immutable (i.e. the returned memory region is not further modified)
|
||||
* once the dispatch data object is passed to other API.
|
||||
*
|
||||
* @param size The size of the required allocation.
|
||||
* @param buffer_ptr A pointer to a pointer variable to be filled with the
|
||||
* location of the newly allocated memory region, or NULL.
|
||||
* @result A newly created dispatch data object.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(6.0))
|
||||
DISPATCH_EXPORT DISPATCH_RETURNS_RETAINED
|
||||
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
|
||||
dispatch_data_t
|
||||
dispatch_data_create_alloc(size_t size, void *_Nullable *_Nullable buffer_ptr);
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_data_applier_function_t
|
||||
* A function to be invoked for every contiguous memory region in a data object.
|
||||
*
|
||||
* @param context Application-defined context parameter.
|
||||
* @param region A data object representing the current region.
|
||||
* @param offset The logical offset of the current region to the start
|
||||
* of the data object.
|
||||
* @param buffer The location of the memory for the current region.
|
||||
* @param size The size of the memory for the current region.
|
||||
* @result A Boolean indicating whether traversal should continue.
|
||||
*/
|
||||
typedef bool (*dispatch_data_applier_function_t)(void *_Nullable context,
|
||||
dispatch_data_t region, size_t offset, const void *buffer, size_t size);
|
||||
|
||||
/*!
|
||||
* @function dispatch_data_apply_f
|
||||
* Traverse the memory regions represented by the specified dispatch data object
|
||||
* in logical order and invoke the specified function once for every contiguous
|
||||
* memory region encountered.
|
||||
*
|
||||
* Each invocation of the function is passed a data object representing the
|
||||
* current region and its logical offset, along with the memory location and
|
||||
* extent of the region. These allow direct read access to the memory region,
|
||||
* but are only valid until the passed-in region object is released. Note that
|
||||
* the region object is released by the system when the function returns, it is
|
||||
* the responsibility of the application to retain it if the region object or
|
||||
* the associated memory location are needed after the function returns.
|
||||
*
|
||||
* @param data The data object to traverse.
|
||||
* @param context The application-defined context to pass to the function.
|
||||
* @param applier The function to be invoked for every contiguous memory
|
||||
* region in the data object.
|
||||
* @result A Boolean indicating whether traversal completed
|
||||
* successfully.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(6.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
bool
|
||||
dispatch_data_apply_f(dispatch_data_t data, void *_Nullable context,
|
||||
dispatch_data_applier_function_t applier);
|
||||
|
||||
#if TARGET_OS_MAC
|
||||
/*!
|
||||
* @function dispatch_data_make_memory_entry
|
||||
* Return a mach memory entry for the memory regions represented by the
|
||||
* specified dispatch data object.
|
||||
*
|
||||
* For data objects created with the DISPATCH_DATA_DESTRUCTOR_VM_DEALLOCATE
|
||||
* destructor, directly makes a memory entry from the represented region;
|
||||
* otherwise, makes a memory entry from newly allocated pages containing a copy
|
||||
* of the represented memory regions.
|
||||
*
|
||||
* @param data The data object to make a memory entry for.
|
||||
* @result A mach port for the newly made memory entry, or
|
||||
* MACH_PORT_NULL if an error occurred.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(6.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
mach_port_t
|
||||
dispatch_data_make_memory_entry(dispatch_data_t data);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @functiongroup Dispatch data transform SPI
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_data_format_type_t
|
||||
*
|
||||
* @abstract
|
||||
* Data formats are used to specify the input and output types of data supplied
|
||||
* to dispatch_data_create_transform.
|
||||
*/
|
||||
typedef const struct dispatch_data_format_type_s *dispatch_data_format_type_t;
|
||||
|
||||
#define DISPATCH_DATA_FORMAT_TYPE_DECL(name) \
|
||||
DISPATCH_EXPORT const struct dispatch_data_format_type_s \
|
||||
_dispatch_data_format_type_##name
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_DATA_FORMAT_TYPE_NONE
|
||||
* @discussion A data format denoting that the given input or output format is,
|
||||
* or should be, comprised of raw data bytes with no given encoding.
|
||||
*/
|
||||
#define DISPATCH_DATA_FORMAT_TYPE_NONE (&_dispatch_data_format_type_none)
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
DISPATCH_DATA_FORMAT_TYPE_DECL(none);
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_DATA_FORMAT_TYPE_BASE32
|
||||
* @discussion A data format denoting that the given input or output format is,
|
||||
* or should be, encoded in Base32 (RFC 4648) format. On input, this format will
|
||||
* skip whitespace characters. Cannot be used in conjunction with UTF format
|
||||
* types.
|
||||
*/
|
||||
#define DISPATCH_DATA_FORMAT_TYPE_BASE32 (&_dispatch_data_format_type_base32)
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
DISPATCH_DATA_FORMAT_TYPE_DECL(base32);
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_DATA_FORMAT_TYPE_BASE32HEX
|
||||
* @discussion A data format denoting that the given input or output format is,
|
||||
* or should be, encoded in Base32Hex (RFC 4648) format. On input, this format
|
||||
* will skip whitespace characters. Cannot be used in conjunction with UTF
|
||||
* format types.
|
||||
*/
|
||||
#define DISPATCH_DATA_FORMAT_TYPE_BASE32HEX \
|
||||
(&_dispatch_data_format_type_base32hex)
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_DATA_FORMAT_TYPE_DECL(base32hex);
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_DATA_FORMAT_TYPE_BASE64
|
||||
* @discussion A data format denoting that the given input or output format is,
|
||||
* or should be, encoded in Base64 (RFC 4648) format. On input, this format will
|
||||
* skip whitespace characters. Cannot be used in conjunction with UTF format
|
||||
* types.
|
||||
*/
|
||||
#define DISPATCH_DATA_FORMAT_TYPE_BASE64 (&_dispatch_data_format_type_base64)
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
DISPATCH_DATA_FORMAT_TYPE_DECL(base64);
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_DATA_FORMAT_TYPE_UTF8
|
||||
* @discussion A data format denoting that the given input or output format is,
|
||||
* or should be, encoded in UTF-8 format. Is only valid when used in conjunction
|
||||
* with other UTF format types.
|
||||
*/
|
||||
#define DISPATCH_DATA_FORMAT_TYPE_UTF8 (&_dispatch_data_format_type_utf8)
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
DISPATCH_DATA_FORMAT_TYPE_DECL(utf8);
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_DATA_FORMAT_TYPE_UTF16LE
|
||||
* @discussion A data format denoting that the given input or output format is,
|
||||
* or should be, encoded in UTF-16LE format. Is only valid when used in
|
||||
* conjunction with other UTF format types.
|
||||
*/
|
||||
#define DISPATCH_DATA_FORMAT_TYPE_UTF16LE (&_dispatch_data_format_type_utf16le)
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
DISPATCH_DATA_FORMAT_TYPE_DECL(utf16le);
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_DATA_FORMAT_TYPE_UTF16BE
|
||||
* @discussion A data format denoting that the given input or output format is,
|
||||
* or should be, encoded in UTF-16BE format. Is only valid when used in
|
||||
* conjunction with other UTF format types.
|
||||
*/
|
||||
#define DISPATCH_DATA_FORMAT_TYPE_UTF16BE (&_dispatch_data_format_type_utf16be)
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
DISPATCH_DATA_FORMAT_TYPE_DECL(utf16be);
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_DATA_FORMAT_TYPE_UTFANY
|
||||
* @discussion A data format denoting that dispatch_data_create_transform should
|
||||
* attempt to automatically detect the input type based on the presence of a
|
||||
* byte order mark character at the beginning of the data. In the absence of a
|
||||
* BOM, the data will be assumed to be in UTF-8 format. Only valid as an input
|
||||
* format.
|
||||
*/
|
||||
#define DISPATCH_DATA_FORMAT_TYPE_UTF_ANY (&_dispatch_data_format_type_utf_any)
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
DISPATCH_DATA_FORMAT_TYPE_DECL(utf_any);
|
||||
|
||||
/*!
|
||||
* @function dispatch_data_create_transform
|
||||
* Returns a new dispatch data object after transforming the given data object
|
||||
* from the supplied format, into the given output format.
|
||||
*
|
||||
* @param data
|
||||
* The data object representing the region(s) of memory to transform.
|
||||
* @param input_type
|
||||
* Flags specifying the input format of the source dispatch_data_t
|
||||
*
|
||||
* @param output_type
|
||||
* Flags specifying the expected output format of the resulting transformation.
|
||||
*
|
||||
* @result
|
||||
* A newly created dispatch data object, dispatch_data_empty if no has been
|
||||
* produced, or NULL if an error occurred.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_RETURNS_RETAINED
|
||||
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
|
||||
dispatch_data_t
|
||||
dispatch_data_create_with_transform(dispatch_data_t data,
|
||||
dispatch_data_format_type_t input_type,
|
||||
dispatch_data_format_type_t output_type);
|
||||
|
||||
/*!
|
||||
* @function dispatch_data_get_flattened_bytes_4libxpc
|
||||
*
|
||||
* Similar to dispatch_data_create_map() but attaches it to the passed in
|
||||
* dispatch data.
|
||||
*
|
||||
* The returned mapping, if not NULL, has the size returned by
|
||||
* dispatch_data_get_size() for the specified object, and its lifetime is tied
|
||||
* to the one of the dispatch data itself.
|
||||
*
|
||||
* @discussion
|
||||
* This interface is reserved for XPC usage and is not considered stable ABI.
|
||||
*
|
||||
*
|
||||
* @result
|
||||
* A newly created linear mapping for this data object, may return NULL if
|
||||
* making the dispatch data contiguous failed to allocate memory.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0), bridgeos(4.0))
|
||||
const void *_Nullable
|
||||
dispatch_data_get_flattened_bytes_4libxpc(dispatch_data_t data);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_END
|
||||
|
||||
#endif // __DISPATCH_DATA_PRIVATE__
|
||||
10
Telegram/ThirdParty/dispatch/private/generic/module.modulemap
vendored
Normal file
10
Telegram/ThirdParty/dispatch/private/generic/module.modulemap
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
module DispatchPrivate [system] [extern_c] {
|
||||
umbrella header "private.h"
|
||||
exclude header "mach_private.h"
|
||||
export *
|
||||
}
|
||||
|
||||
module DispatchIntrospectionPrivate [system] [extern_c] {
|
||||
header "introspection_private.h"
|
||||
export *
|
||||
}
|
||||
871
Telegram/ThirdParty/dispatch/private/introspection_private.h
vendored
Normal file
871
Telegram/ThirdParty/dispatch/private/introspection_private.h
vendored
Normal file
@@ -0,0 +1,871 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2013 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
* IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
|
||||
* which are subject to change in future releases of Mac OS X. Any applications
|
||||
* relying on these interfaces WILL break.
|
||||
*/
|
||||
|
||||
#ifndef __DISPATCH_INTROSPECTION_PRIVATE__
|
||||
#define __DISPATCH_INTROSPECTION_PRIVATE__
|
||||
|
||||
/*!
|
||||
* @header
|
||||
*
|
||||
* @abstract
|
||||
* Introspection SPI for libdispatch.
|
||||
*
|
||||
* @discussion
|
||||
* This SPI is only available in the introspection version of the library,
|
||||
* loaded by running a process with the environment variable
|
||||
* DYLD_LIBRARY_PATH=/usr/lib/system/introspection
|
||||
*
|
||||
* NOTE: most of these functions are _not_ exported from the shared library,
|
||||
* the unexported functions are intended to only be called from a debugger
|
||||
* context while the rest of the process is suspended.
|
||||
*/
|
||||
|
||||
#ifndef __BEGIN_DECLS
|
||||
#if defined(__cplusplus)
|
||||
#define __BEGIN_DECLS extern "C" {
|
||||
#define __END_DECLS }
|
||||
#else
|
||||
#define __BEGIN_DECLS
|
||||
#define __END_DECLS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#ifndef __DISPATCH_INDIRECT__
|
||||
/*
|
||||
* Typedefs of opaque types, for direct inclusion of header in lldb expressions
|
||||
*/
|
||||
typedef __typeof__(sizeof(int)) size_t;
|
||||
typedef struct _opaque_pthread_t *pthread_t;
|
||||
typedef void (*dispatch_function_t)(void *);
|
||||
typedef struct Block_layout *dispatch_block_t;
|
||||
typedef struct dispatch_continuation_s *dispatch_continuation_t;
|
||||
typedef struct dispatch_queue_s *dispatch_queue_t;
|
||||
typedef struct dispatch_source_s *dispatch_source_t;
|
||||
typedef struct dispatch_group_s *dispatch_group_t;
|
||||
typedef struct dispatch_object_s *dispatch_object_t;
|
||||
#ifndef API_AVAILABLE
|
||||
#define API_AVAILABLE(...)
|
||||
#endif
|
||||
#ifndef DISPATCH_EXPORT
|
||||
#define DISPATCH_EXPORT extern
|
||||
#endif
|
||||
#endif // __DISPATCH_INDIRECT__
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_versions_s
|
||||
*
|
||||
* @abstract
|
||||
* A structure of version and size information of introspection structures.
|
||||
*
|
||||
* @field introspection_version
|
||||
* Version of overall dispatch_introspection SPI.
|
||||
*
|
||||
* @field hooks_version
|
||||
* Version of dispatch_introspection_hooks_s structure.
|
||||
* Version 2 adds the queue_item_complete member.
|
||||
*
|
||||
* @field hooks_size
|
||||
* Size of dispatch_introspection_hooks_s structure.
|
||||
*
|
||||
* @field queue_item_version
|
||||
* Version of dispatch_introspection_queue_item_s structure.
|
||||
*
|
||||
* @field queue_item_size
|
||||
* Size of dispatch_introspection_queue_item_s structure.
|
||||
*
|
||||
* @field queue_block_version
|
||||
* Version of dispatch_introspection_queue_block_s structure.
|
||||
*
|
||||
* @field queue_block_size
|
||||
* Size of dispatch_introspection_queue_block_s structure.
|
||||
*
|
||||
* @field queue_function_version
|
||||
* Version of dispatch_introspection_queue_function_s structure.
|
||||
*
|
||||
* @field queue_function_size
|
||||
* Size of dispatch_introspection_queue_function_s structure.
|
||||
*
|
||||
* @field queue_thread_version
|
||||
* Version of dispatch_introspection_queue_thread_s structure.
|
||||
*
|
||||
* @field queue_thread_size
|
||||
* Size of dispatch_introspection_queue_thread_s structure.
|
||||
*
|
||||
* @field object_version
|
||||
* Version of dispatch_introspection_object_s structure.
|
||||
*
|
||||
* @field object_size
|
||||
* Size of dispatch_introspection_object_s structure.
|
||||
*
|
||||
* @field queue_version
|
||||
* Version of dispatch_introspection_queue_s structure.
|
||||
*
|
||||
* @field queue_size
|
||||
* Size of dispatch_introspection_queue_s structure.
|
||||
*
|
||||
* @field source_version
|
||||
* Version of dispatch_introspection_source_s structure.
|
||||
*
|
||||
* @field source_size
|
||||
* Size of dispatch_introspection_source_s structure.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT const struct dispatch_introspection_versions_s {
|
||||
unsigned long introspection_version;
|
||||
unsigned long hooks_version;
|
||||
size_t hooks_size;
|
||||
unsigned long queue_item_version;
|
||||
size_t queue_item_size;
|
||||
unsigned long queue_block_version;
|
||||
size_t queue_block_size;
|
||||
unsigned long queue_function_version;
|
||||
size_t queue_function_size;
|
||||
unsigned long queue_thread_version;
|
||||
size_t queue_thread_size;
|
||||
unsigned long object_version;
|
||||
size_t object_size;
|
||||
unsigned long queue_version;
|
||||
size_t queue_size;
|
||||
unsigned long source_version;
|
||||
size_t source_size;
|
||||
} dispatch_introspection_versions;
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_queue_block_s
|
||||
*
|
||||
* @abstract
|
||||
* A structure of introspection information for a block item enqueued on a
|
||||
* dispatch queue.
|
||||
*
|
||||
* @field continuation
|
||||
* Pointer to enqueued item.
|
||||
*
|
||||
* @field target_queue
|
||||
* Target queue of item (may be different to the queue the item is currently
|
||||
* enqueued on).
|
||||
*
|
||||
* @field block
|
||||
* Block for enqueued item.
|
||||
*
|
||||
* @field block_invoke
|
||||
* Function pointer of block for enqueued item.
|
||||
*
|
||||
* @field group
|
||||
* Group containing enqueued item (may be NULL).
|
||||
*
|
||||
* @field waiter
|
||||
* Thread waiting for completion of enqueued item (NULL if sync == 0).
|
||||
*
|
||||
* @field barrier
|
||||
* Item is a barrier on the queue (all items on serial queues are barriers).
|
||||
*
|
||||
* @field sync
|
||||
* Item was enqueued by a dispatch_sync/dispatch_barrier_sync.
|
||||
*
|
||||
* @field apply
|
||||
* Item is part of a dispatch_apply.
|
||||
*/
|
||||
typedef struct dispatch_introspection_queue_block_s {
|
||||
dispatch_continuation_t continuation;
|
||||
dispatch_queue_t target_queue;
|
||||
dispatch_block_t block;
|
||||
dispatch_function_t block_invoke;
|
||||
dispatch_group_t group;
|
||||
pthread_t waiter;
|
||||
unsigned long barrier:1,
|
||||
sync:1,
|
||||
apply:1;
|
||||
} dispatch_introspection_queue_block_s;
|
||||
typedef dispatch_introspection_queue_block_s
|
||||
*dispatch_introspection_queue_block_t;
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_queue_function_s
|
||||
*
|
||||
* @abstract
|
||||
* A structure of introspection information for a function & context pointer
|
||||
* item enqueued on a dispatch queue.
|
||||
*
|
||||
* @field continuation
|
||||
* Pointer to enqueued item.
|
||||
*
|
||||
* @field target_queue
|
||||
* Target queue of item (may be different to the queue the item is currently
|
||||
* enqueued on).
|
||||
*
|
||||
* @field context
|
||||
* Context in enqueued item.
|
||||
*
|
||||
* @field block_invoke
|
||||
* Function pointer in enqueued item.
|
||||
*
|
||||
* @field group
|
||||
* Group containing enqueued item (may be NULL).
|
||||
*
|
||||
* @field waiter
|
||||
* Thread waiting for completion of enqueued item (NULL if sync == 0).
|
||||
*
|
||||
* @field barrier
|
||||
* Item is a barrier on the queue (all items on serial queues are barriers).
|
||||
*
|
||||
* @field sync
|
||||
* Item was enqueued by a dispatch_sync_f/dispatch_barrier_sync_f.
|
||||
*
|
||||
* @field apply
|
||||
* Item is part of a dispatch_apply_f.
|
||||
*/
|
||||
typedef struct dispatch_introspection_queue_function_s {
|
||||
dispatch_continuation_t continuation;
|
||||
dispatch_queue_t target_queue;
|
||||
void *context;
|
||||
dispatch_function_t function;
|
||||
dispatch_group_t group;
|
||||
pthread_t waiter;
|
||||
unsigned long barrier:1,
|
||||
sync:1,
|
||||
apply:1;
|
||||
} dispatch_introspection_queue_function_s;
|
||||
typedef dispatch_introspection_queue_function_s
|
||||
*dispatch_introspection_queue_function_t;
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_object_s
|
||||
*
|
||||
* @abstract
|
||||
* A structure of introspection information for a generic dispatch object.
|
||||
*
|
||||
* @field object
|
||||
* Pointer to object.
|
||||
*
|
||||
* @field target_queue
|
||||
* Target queue of object (may be different to the queue the object is
|
||||
* currently enqueued on).
|
||||
*
|
||||
* @field type
|
||||
* Object class pointer.
|
||||
*
|
||||
* @field kind
|
||||
* String describing the object type.
|
||||
*/
|
||||
typedef struct dispatch_introspection_object_s {
|
||||
dispatch_continuation_t object;
|
||||
dispatch_queue_t target_queue;
|
||||
void *type;
|
||||
const char *kind;
|
||||
} dispatch_introspection_object_s;
|
||||
typedef dispatch_introspection_object_s *dispatch_introspection_object_t;
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_queue_s
|
||||
*
|
||||
* @abstract
|
||||
* A structure of introspection information for a dispatch queue.
|
||||
*
|
||||
* @field queue
|
||||
* Pointer to queue object.
|
||||
*
|
||||
* @field target_queue
|
||||
* Target queue of queue (may be different to the queue the queue is currently
|
||||
* enqueued on). NULL indicates queue is a root queue.
|
||||
*
|
||||
* @field label
|
||||
* Pointer to queue label.
|
||||
*
|
||||
* @field serialnum
|
||||
* Queue serial number (unique per process).
|
||||
*
|
||||
* @field width
|
||||
* Queue width (1: serial queue, UINT_MAX: concurrent queue).
|
||||
*
|
||||
* @field suspend_count
|
||||
* Number of times the queue has been suspended.
|
||||
*
|
||||
* @field enqueued
|
||||
* Queue is enqueued on another queue.
|
||||
*
|
||||
* @field barrier
|
||||
* Queue is executing a barrier item.
|
||||
*
|
||||
* @field draining
|
||||
* Queue is being drained (cannot get queue items).
|
||||
*
|
||||
* @field global
|
||||
* Queue is a global queue.
|
||||
*
|
||||
* @field main
|
||||
* Queue is the main queue.
|
||||
*/
|
||||
typedef struct dispatch_introspection_queue_s {
|
||||
dispatch_queue_t queue;
|
||||
dispatch_queue_t target_queue;
|
||||
const char *label;
|
||||
unsigned long serialnum;
|
||||
unsigned int width;
|
||||
unsigned int suspend_count;
|
||||
unsigned long enqueued:1,
|
||||
barrier:1,
|
||||
draining:1,
|
||||
global:1,
|
||||
main:1;
|
||||
} dispatch_introspection_queue_s;
|
||||
typedef dispatch_introspection_queue_s *dispatch_introspection_queue_t;
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_source_s
|
||||
*
|
||||
* @abstract
|
||||
* A structure of introspection information for a dispatch source.
|
||||
*
|
||||
* @field source
|
||||
* Pointer to source object.
|
||||
*
|
||||
* @field target_queue
|
||||
* Target queue of source (may be different to the queue the source is currently
|
||||
* enqueued on).
|
||||
*
|
||||
* @field type
|
||||
* Source type (kevent filter)
|
||||
*
|
||||
* @field handle
|
||||
* Source handle (monitored entity).
|
||||
*
|
||||
* @field context
|
||||
* Context pointer passed to source handler. Pointer to handler block if
|
||||
* handler_is_block == 1.
|
||||
*
|
||||
* @field handler
|
||||
* Source handler function. Function pointer of handler block if
|
||||
* handler_is_block == 1.
|
||||
*
|
||||
* @field suspend_count
|
||||
* Number of times the source has been suspended.
|
||||
*
|
||||
* @field enqueued
|
||||
* Source is enqueued on a queue.
|
||||
*
|
||||
* @field handler_is_block
|
||||
* Source handler is a block.
|
||||
*
|
||||
* @field timer
|
||||
* Source is a timer.
|
||||
*
|
||||
* @field after
|
||||
* Source is a dispatch_after timer.
|
||||
*/
|
||||
typedef struct dispatch_introspection_source_s {
|
||||
dispatch_source_t source;
|
||||
dispatch_queue_t target_queue;
|
||||
unsigned long type;
|
||||
unsigned long handle;
|
||||
void *context;
|
||||
dispatch_function_t handler;
|
||||
unsigned int suspend_count;
|
||||
unsigned long enqueued:1,
|
||||
handler_is_block:1,
|
||||
timer:1,
|
||||
after:1,
|
||||
is_xpc:1;
|
||||
} dispatch_introspection_source_s;
|
||||
typedef dispatch_introspection_source_s *dispatch_introspection_source_t;
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_queue_thread_s
|
||||
*
|
||||
* @abstract
|
||||
* A structure of introspection information about a thread executing items for
|
||||
* a dispatch queue.
|
||||
*
|
||||
* @field object
|
||||
* Pointer to thread object.
|
||||
*
|
||||
* @field thread
|
||||
* Thread executing items for a queue.
|
||||
*
|
||||
* @field queue
|
||||
* Queue introspection information. The queue.queue field is NULL if this thread
|
||||
* is not currently executing items for a queue.
|
||||
*/
|
||||
typedef struct dispatch_introspection_queue_thread_s {
|
||||
dispatch_continuation_t object;
|
||||
pthread_t thread;
|
||||
dispatch_introspection_queue_s queue;
|
||||
} dispatch_introspection_queue_thread_s;
|
||||
typedef dispatch_introspection_queue_thread_s
|
||||
*dispatch_introspection_queue_thread_t;
|
||||
|
||||
/*!
|
||||
* @enum dispatch_introspection_queue_item_type
|
||||
*
|
||||
* @abstract
|
||||
* Types of items enqueued on a dispatch queue.
|
||||
*/
|
||||
enum dispatch_introspection_queue_item_type {
|
||||
dispatch_introspection_queue_item_type_none = 0x0,
|
||||
dispatch_introspection_queue_item_type_block = 0x11,
|
||||
dispatch_introspection_queue_item_type_function = 0x12,
|
||||
dispatch_introspection_queue_item_type_object = 0x100,
|
||||
dispatch_introspection_queue_item_type_queue = 0x101,
|
||||
dispatch_introspection_queue_item_type_source = 0x42,
|
||||
};
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_queue_item_s
|
||||
*
|
||||
* @abstract
|
||||
* A structure of introspection information about an item enqueued on a
|
||||
* dispatch queue.
|
||||
*
|
||||
* @field type
|
||||
* Indicates which of the union members applies to this item.
|
||||
*/
|
||||
typedef struct dispatch_introspection_queue_item_s {
|
||||
unsigned long type; // dispatch_introspection_queue_item_type
|
||||
union {
|
||||
dispatch_introspection_queue_block_s block;
|
||||
dispatch_introspection_queue_function_s function;
|
||||
dispatch_introspection_object_s object;
|
||||
dispatch_introspection_queue_s queue;
|
||||
dispatch_introspection_source_s source;
|
||||
};
|
||||
} dispatch_introspection_queue_item_s;
|
||||
typedef dispatch_introspection_queue_item_s
|
||||
*dispatch_introspection_queue_item_t;
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_hook_queue_create_t
|
||||
*
|
||||
* @abstract
|
||||
* A function pointer called when a dispatch queue is created.
|
||||
*
|
||||
* @param queue_info
|
||||
* Pointer to queue introspection structure.
|
||||
*/
|
||||
typedef void (*dispatch_introspection_hook_queue_create_t)(
|
||||
dispatch_introspection_queue_t queue_info);
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_hook_queue_dispose_t
|
||||
*
|
||||
* @abstract
|
||||
* A function pointer called when a dispatch queue is destroyed.
|
||||
*
|
||||
* @param queue_info
|
||||
* Pointer to queue introspection structure.
|
||||
*/
|
||||
typedef void (*dispatch_introspection_hook_queue_dispose_t)(
|
||||
dispatch_introspection_queue_t queue_info);
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_hook_queue_item_enqueue_t
|
||||
*
|
||||
* @abstract
|
||||
* A function pointer called when an item is enqueued onto a dispatch queue.
|
||||
*
|
||||
* @param queue
|
||||
* Pointer to queue.
|
||||
*
|
||||
* @param item
|
||||
* Pointer to item introspection structure.
|
||||
*/
|
||||
typedef void (*dispatch_introspection_hook_queue_item_enqueue_t)(
|
||||
dispatch_queue_t queue, dispatch_introspection_queue_item_t item);
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_hook_queue_item_dequeue_t
|
||||
*
|
||||
* @abstract
|
||||
* A function pointer called when an item is dequeued from a dispatch queue.
|
||||
*
|
||||
* @param queue
|
||||
* Pointer to queue.
|
||||
*
|
||||
* @param item
|
||||
* Pointer to item introspection structure.
|
||||
*/
|
||||
typedef void (*dispatch_introspection_hook_queue_item_dequeue_t)(
|
||||
dispatch_queue_t queue, dispatch_introspection_queue_item_t item);
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_hook_queue_item_complete_t
|
||||
*
|
||||
* @abstract
|
||||
* A function pointer called when an item previously dequeued from a dispatch
|
||||
* queue has completed processing.
|
||||
*
|
||||
* @discussion
|
||||
* The object pointer value passed to this function pointer must be treated as a
|
||||
* value only. It is intended solely for matching up with an earlier call to a
|
||||
* dequeue hook function pointer by comparing to the first member of the
|
||||
* dispatch_introspection_queue_item_t structure. It must NOT be dereferenced
|
||||
* or e.g. passed to dispatch_introspection_queue_item_get_info(), the memory
|
||||
* that was backing it may have been reused at the time this hook is called.
|
||||
*
|
||||
* @param object
|
||||
* Opaque dentifier for completed item. Must NOT be dereferenced.
|
||||
*/
|
||||
typedef void (*dispatch_introspection_hook_queue_item_complete_t)(
|
||||
dispatch_continuation_t object);
|
||||
|
||||
/*!
|
||||
* @enum dispatch_introspection_runtime_event
|
||||
*
|
||||
* @abstract
|
||||
* Types for major events the dispatch runtime goes through as sent by
|
||||
* the runtime_event hook.
|
||||
*
|
||||
* @const dispatch_introspection_runtime_event_worker_event_delivery
|
||||
* A worker thread was unparked to deliver some kernel events.
|
||||
* There may be an unpark event if the thread will pick up a queue to drain.
|
||||
* There always is a worker_park event when the thread is returned to the pool.
|
||||
* `ptr` is the queue for which events are being delivered, or NULL (for generic
|
||||
* events).
|
||||
* `value` is the number of events delivered.
|
||||
*
|
||||
* @const dispatch_introspection_runtime_event_worker_unpark
|
||||
* A worker thread junst unparked (sent from the context of the thread).
|
||||
* `ptr` is the queue for which the thread unparked.
|
||||
* `value` is 0.
|
||||
*
|
||||
* @const dispatch_introspection_runtime_event_worker_request
|
||||
* `ptr` is set to the queue on behalf of which the thread request is made.
|
||||
* `value` is the number of threads requested.
|
||||
*
|
||||
* @const dispatch_introspection_runtime_event_worker_park
|
||||
* A worker thread is about to park (sent from the context of the thread).
|
||||
* `ptr` and `value` are 0.
|
||||
*
|
||||
* @const dispatch_introspection_runtime_event_sync_wait
|
||||
* A caller of dispatch_sync or dispatch_async_and_wait hit contention.
|
||||
* `ptr` is the queue that caused the initial contention.
|
||||
* `value` is 0.
|
||||
*
|
||||
* @const dispatch_introspection_runtime_event_async_sync_handoff
|
||||
* @const dispatch_introspection_runtime_event_sync_sync_handoff
|
||||
* @const dispatch_introspection_runtime_event_sync_async_handoff
|
||||
*
|
||||
* A queue is being handed off from a thread to another due to respectively:
|
||||
* - async/sync contention
|
||||
* - sync/sync contention
|
||||
* - sync/async contention
|
||||
*
|
||||
* `ptr` is set to dispatch_queue_t which is handed off to the next thread.
|
||||
* `value` is 0.
|
||||
*/
|
||||
#ifndef __DISPATCH_BUILDING_DISPATCH__
|
||||
enum dispatch_introspection_runtime_event {
|
||||
dispatch_introspection_runtime_event_worker_event_delivery = 1,
|
||||
dispatch_introspection_runtime_event_worker_unpark = 2,
|
||||
dispatch_introspection_runtime_event_worker_request = 3,
|
||||
dispatch_introspection_runtime_event_worker_park = 4,
|
||||
|
||||
dispatch_introspection_runtime_event_sync_wait = 10,
|
||||
dispatch_introspection_runtime_event_async_sync_handoff = 11,
|
||||
dispatch_introspection_runtime_event_sync_sync_handoff = 12,
|
||||
dispatch_introspection_runtime_event_sync_async_handoff = 13,
|
||||
};
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_hook_runtime_event_t
|
||||
*
|
||||
* @abstract
|
||||
* A function pointer called for various runtime events.
|
||||
*
|
||||
* @discussion
|
||||
* The actual payloads are discussed in the documentation of the
|
||||
* dispatch_introspection_runtime_event enum.
|
||||
*/
|
||||
typedef void (*dispatch_introspection_hook_runtime_event_t)(
|
||||
enum dispatch_introspection_runtime_event event,
|
||||
void *ptr, unsigned long long value);
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_introspection_hooks_s
|
||||
*
|
||||
* @abstract
|
||||
* A structure of function pointer hooks into libdispatch.
|
||||
*/
|
||||
typedef struct dispatch_introspection_hooks_s {
|
||||
dispatch_introspection_hook_queue_create_t queue_create;
|
||||
dispatch_introspection_hook_queue_dispose_t queue_dispose;
|
||||
dispatch_introspection_hook_queue_item_enqueue_t queue_item_enqueue;
|
||||
dispatch_introspection_hook_queue_item_dequeue_t queue_item_dequeue;
|
||||
dispatch_introspection_hook_queue_item_complete_t queue_item_complete;
|
||||
dispatch_introspection_hook_runtime_event_t runtime_event;
|
||||
void *_reserved[4];
|
||||
} dispatch_introspection_hooks_s;
|
||||
typedef dispatch_introspection_hooks_s *dispatch_introspection_hooks_t;
|
||||
|
||||
/*!
|
||||
* @function dispatch_introspection_get_queues
|
||||
*
|
||||
* @abstract
|
||||
* Retrieve introspection information about all dispatch queues in the process,
|
||||
* in batches of specified size.
|
||||
*
|
||||
* @discussion
|
||||
* Retrieving queue information and iterating through the list of all queues
|
||||
* must take place from a debugger context (while the rest of the process is
|
||||
* suspended).
|
||||
*
|
||||
* @param start
|
||||
* Starting point for this batch of queue information, as returned by a previous
|
||||
* call to _dispatch_introspection_get_queues().
|
||||
* Pass NULL to retrieve the initial batch.
|
||||
*
|
||||
* @param count
|
||||
* Number of queues to introspect.
|
||||
*
|
||||
* @param queues
|
||||
* Array to fill with queue information. If less than 'count' queues are left
|
||||
* in this batch, the end of valid entries in the array will be indicated
|
||||
* by an entry with NULL queue member.
|
||||
*
|
||||
* @result
|
||||
* Queue to pass to another call to _dispatch_introspection_get_queues() to
|
||||
* retrieve information about the next batch of queues. May be NULL if there
|
||||
* are no more queues to iterate over.
|
||||
*/
|
||||
extern dispatch_queue_t
|
||||
dispatch_introspection_get_queues(dispatch_queue_t start, size_t count,
|
||||
dispatch_introspection_queue_t queues);
|
||||
|
||||
/*!
|
||||
* @function dispatch_introspection_get_queue_threads
|
||||
*
|
||||
* @abstract
|
||||
* Retrieve introspection information about all threads in the process executing
|
||||
* items for dispatch queues, in batches of specified size.
|
||||
*
|
||||
* @discussion
|
||||
* Retrieving thread information and iterating through the list of all queue
|
||||
* threads must take place from a debugger context (while the rest of the
|
||||
* process is suspended).
|
||||
*
|
||||
* @param start
|
||||
* Starting point for this batch of thread information, as returned by a
|
||||
* previous call to _dispatch_introspection_get_queue_threads().
|
||||
* Pass NULL to retrieve the initial batch.
|
||||
*
|
||||
* @param count
|
||||
* Number of queue threads to introspect.
|
||||
*
|
||||
* @param threads
|
||||
* Array to fill with queue thread information. If less than 'count' threads are
|
||||
* left in this batch, the end of valid entries in the array will be indicated
|
||||
* by an entry with NULL object member.
|
||||
*
|
||||
* @result
|
||||
* Object to pass to another call to _dispatch_introspection_get_queues() to
|
||||
* retrieve information about the next batch of queues. May be NULL if there
|
||||
* are no more queues to iterate over.
|
||||
*/
|
||||
extern dispatch_continuation_t
|
||||
dispatch_introspection_get_queue_threads(dispatch_continuation_t start,
|
||||
size_t count, dispatch_introspection_queue_thread_t threads);
|
||||
|
||||
/*!
|
||||
* @function dispatch_introspection_queue_get_items
|
||||
*
|
||||
* @abstract
|
||||
* Retrieve introspection information about all items enqueued on a queue, in
|
||||
* batches of specified size.
|
||||
*
|
||||
* @discussion
|
||||
* Retrieving queue item information and iterating through a queue must take
|
||||
* place from a debugger context (while the rest of the process is suspended).
|
||||
*
|
||||
* @param queue
|
||||
* Queue to introspect.
|
||||
*
|
||||
* @param start
|
||||
* Starting point for this batch of queue item information, as returned by a
|
||||
* previous call to _dispatch_introspection_queue_get_items().
|
||||
* Pass NULL to retrieve the initial batch.
|
||||
*
|
||||
* @param count
|
||||
* Number of items to introspect.
|
||||
*
|
||||
* @param items
|
||||
* Array to fill with queue item information. If less than 'count' queues are
|
||||
* left in this batch, the end of valid entries in the array will be indicated
|
||||
* by an entry with type dispatch_introspection_queue_item_type_none.
|
||||
*
|
||||
* @result
|
||||
* Item to pass to another call to _dispatch_introspection_queue_get_items() to
|
||||
* retrieve information about the next batch of queue items. May be NULL if
|
||||
* there are no more items to iterate over.
|
||||
*/
|
||||
extern dispatch_continuation_t
|
||||
dispatch_introspection_queue_get_items(dispatch_queue_t queue,
|
||||
dispatch_continuation_t start, size_t count,
|
||||
dispatch_introspection_queue_item_t items);
|
||||
|
||||
/*!
|
||||
* @function dispatch_introspection_queue_get_info
|
||||
*
|
||||
* @abstract
|
||||
* Retrieve introspection information about a specified dispatch queue.
|
||||
*
|
||||
* @discussion
|
||||
* Retrieving queue information must take place from a debugger context (while
|
||||
* the rest of the process is suspended).
|
||||
*
|
||||
* @param queue
|
||||
* Queue to introspect.
|
||||
*
|
||||
* @result
|
||||
* Queue information struct.
|
||||
*/
|
||||
extern dispatch_introspection_queue_s
|
||||
dispatch_introspection_queue_get_info(dispatch_queue_t queue);
|
||||
|
||||
/*!
|
||||
* @function dispatch_introspection_queue_item_get_info
|
||||
*
|
||||
* @abstract
|
||||
* Retrieve introspection information about a specified dispatch queue item.
|
||||
*
|
||||
* @discussion
|
||||
* Retrieving queue item information must take place from a debugger context
|
||||
* (while the rest of the process is suspended).
|
||||
*
|
||||
* @param queue
|
||||
* Queue to introspect.
|
||||
*
|
||||
* @param item
|
||||
* Item to introspect.
|
||||
*
|
||||
* @result
|
||||
* Queue item information struct.
|
||||
*/
|
||||
extern dispatch_introspection_queue_item_s
|
||||
dispatch_introspection_queue_item_get_info(dispatch_queue_t queue,
|
||||
dispatch_continuation_t item);
|
||||
|
||||
/*!
|
||||
* @function dispatch_introspection_hooks_install
|
||||
*
|
||||
* @abstract
|
||||
* Install hook functions into libdispatch.
|
||||
*
|
||||
* @discussion
|
||||
* Installing hook functions must take place from a debugger context (while the
|
||||
* rest of the process is suspended) or early enough in the process lifecycle
|
||||
* that the process is still single-threaded.
|
||||
*
|
||||
* The caller is responsible for implementing chaining to the hooks that were
|
||||
* previously installed (if any).
|
||||
*
|
||||
* @param hooks
|
||||
* Pointer to structure of hook function pointers. Any of the structure members
|
||||
* may be NULL to indicate that the hook in question should not be installed.
|
||||
* The structure is copied on input and filled with the previously installed
|
||||
* hooks on output.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT void
|
||||
dispatch_introspection_hooks_install(dispatch_introspection_hooks_t hooks);
|
||||
|
||||
/*!
|
||||
* @function dispatch_introspection_hook_callouts_enable
|
||||
*
|
||||
* @abstract
|
||||
* Enable hook callout functions in libdispatch that a debugger can break on
|
||||
* and get introspection arguments even if there are no hook functions
|
||||
* installed via dispatch_introspection_hooks_install().
|
||||
*
|
||||
* @discussion
|
||||
* Enabling hook callout functions must take place from a debugger context
|
||||
* (while the rest of the process is suspended).
|
||||
*
|
||||
* @param enable
|
||||
* Pointer to dispatch_introspection_hooks_s structure. For every structure
|
||||
* member with (any) non-NULL value, the corresponding hook callout will be
|
||||
* enabled; for every NULL member the hook callout will be disabled (if there
|
||||
* is no hook function installed).
|
||||
* As a convenience, the 'enable' pointer may itself be NULL to indicate that
|
||||
* all hook callouts should be enabled.
|
||||
*/
|
||||
extern void
|
||||
dispatch_introspection_hook_callouts_enable(
|
||||
dispatch_introspection_hooks_t enable);
|
||||
|
||||
/*!
|
||||
* @function dispatch_introspection_hook_callout_queue_create
|
||||
*
|
||||
* @abstract
|
||||
* Callout to queue creation hook that a debugger can break on.
|
||||
*/
|
||||
extern void
|
||||
dispatch_introspection_hook_callout_queue_create(
|
||||
dispatch_introspection_queue_t queue_info);
|
||||
|
||||
/*!
|
||||
* @function dispatch_introspection_hook_callout_queue_dispose
|
||||
*
|
||||
* @abstract
|
||||
* Callout to queue destruction hook that a debugger can break on.
|
||||
*/
|
||||
extern void
|
||||
dispatch_introspection_hook_callout_queue_dispose(
|
||||
dispatch_introspection_queue_t queue_info);
|
||||
|
||||
/*!
|
||||
* @function dispatch_introspection_hook_callout_queue_item_enqueue
|
||||
*
|
||||
* @abstract
|
||||
* Callout to queue enqueue hook that a debugger can break on.
|
||||
*/
|
||||
extern void
|
||||
dispatch_introspection_hook_callout_queue_item_enqueue(
|
||||
dispatch_queue_t queue, dispatch_introspection_queue_item_t item);
|
||||
|
||||
/*!
|
||||
* @function dispatch_introspection_hook_callout_queue_item_dequeue
|
||||
*
|
||||
* @abstract
|
||||
* Callout to queue dequeue hook that a debugger can break on.
|
||||
*/
|
||||
extern void
|
||||
dispatch_introspection_hook_callout_queue_item_dequeue(
|
||||
dispatch_queue_t queue, dispatch_introspection_queue_item_t item);
|
||||
|
||||
/*!
|
||||
* @function dispatch_introspection_hook_callout_queue_item_complete
|
||||
*
|
||||
* @abstract
|
||||
* Callout to queue item complete hook that a debugger can break on.
|
||||
*/
|
||||
extern void
|
||||
dispatch_introspection_hook_callout_queue_item_complete(
|
||||
dispatch_continuation_t object);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
416
Telegram/ThirdParty/dispatch/private/io_private.h
vendored
Normal file
416
Telegram/ThirdParty/dispatch/private/io_private.h
vendored
Normal file
@@ -0,0 +1,416 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2013 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
* IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
|
||||
* which are subject to change in future releases of Mac OS X. Any applications
|
||||
* relying on these interfaces WILL break.
|
||||
*/
|
||||
|
||||
#ifndef __DISPATCH_IO_PRIVATE__
|
||||
#define __DISPATCH_IO_PRIVATE__
|
||||
|
||||
#ifndef __DISPATCH_INDIRECT__
|
||||
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
|
||||
#include <dispatch/base.h> // for HeaderDoc
|
||||
#endif
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_BEGIN
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*!
|
||||
* @function dispatch_read_f
|
||||
* Schedule a read operation for asynchronous execution on the specified file
|
||||
* descriptor. The specified handler is enqueued with the data read from the
|
||||
* file descriptor when the operation has completed or an error occurs.
|
||||
*
|
||||
* The data object passed to the handler will be automatically released by the
|
||||
* system when the handler returns. It is the responsibility of the application
|
||||
* to retain, concatenate or copy the data object if it is needed after the
|
||||
* handler returns.
|
||||
*
|
||||
* The data object passed to the handler will only contain as much data as is
|
||||
* currently available from the file descriptor (up to the specified length).
|
||||
*
|
||||
* If an unrecoverable error occurs on the file descriptor, the handler will be
|
||||
* enqueued with the appropriate error code along with a data object of any data
|
||||
* that could be read successfully.
|
||||
*
|
||||
* An invocation of the handler with an error code of zero and an empty data
|
||||
* object indicates that EOF was reached.
|
||||
*
|
||||
* The system takes control of the file descriptor until the handler is
|
||||
* enqueued, and during this time file descriptor flags such as O_NONBLOCK will
|
||||
* be modified by the system on behalf of the application. It is an error for
|
||||
* the application to modify a file descriptor directly while it is under the
|
||||
* control of the system, but it may create additional dispatch I/O convenience
|
||||
* operations or dispatch I/O channels associated with that file descriptor.
|
||||
*
|
||||
* @param fd The file descriptor from which to read the data.
|
||||
* @param length The length of data to read from the file descriptor,
|
||||
* or SIZE_MAX to indicate that all of the data currently
|
||||
* available from the file descriptor should be read.
|
||||
* @param queue The dispatch queue to which the handler should be
|
||||
* submitted.
|
||||
* @param context The application-defined context parameter to pass to
|
||||
* the handler function.
|
||||
* @param handler The handler to enqueue when data is ready to be
|
||||
* delivered.
|
||||
* param context Application-defined context parameter.
|
||||
* param data The data read from the file descriptor.
|
||||
* param error An errno condition for the read operation or
|
||||
* zero if the read was successful.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL3 DISPATCH_NONNULL5 DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_read_f(dispatch_fd_t fd,
|
||||
size_t length,
|
||||
dispatch_queue_t queue,
|
||||
void *_Nullable context,
|
||||
void (*handler)(void *_Nullable context, dispatch_data_t data, int error));
|
||||
|
||||
/*!
|
||||
* @function dispatch_write_f
|
||||
* Schedule a write operation for asynchronous execution on the specified file
|
||||
* descriptor. The specified handler is enqueued when the operation has
|
||||
* completed or an error occurs.
|
||||
*
|
||||
* If an unrecoverable error occurs on the file descriptor, the handler will be
|
||||
* enqueued with the appropriate error code along with the data that could not
|
||||
* be successfully written.
|
||||
*
|
||||
* An invocation of the handler with an error code of zero indicates that the
|
||||
* data was fully written to the channel.
|
||||
*
|
||||
* The system takes control of the file descriptor until the handler is
|
||||
* enqueued, and during this time file descriptor flags such as O_NONBLOCK will
|
||||
* be modified by the system on behalf of the application. It is an error for
|
||||
* the application to modify a file descriptor directly while it is under the
|
||||
* control of the system, but it may create additional dispatch I/O convenience
|
||||
* operations or dispatch I/O channels associated with that file descriptor.
|
||||
*
|
||||
* @param fd The file descriptor to which to write the data.
|
||||
* @param data The data object to write to the file descriptor.
|
||||
* @param queue The dispatch queue to which the handler should be
|
||||
* submitted.
|
||||
* @param context The application-defined context parameter to pass to
|
||||
* the handler function.
|
||||
* @param handler The handler to enqueue when the data has been written.
|
||||
* param context Application-defined context parameter.
|
||||
* param data The data that could not be written to the I/O
|
||||
* channel, or NULL.
|
||||
* param error An errno condition for the write operation or
|
||||
* zero if the write was successful.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NONNULL3 DISPATCH_NONNULL5
|
||||
DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_write_f(dispatch_fd_t fd,
|
||||
dispatch_data_t data,
|
||||
dispatch_queue_t queue,
|
||||
void *_Nullable context,
|
||||
void (*handler)(void *_Nullable context, dispatch_data_t _Nullable data,
|
||||
int error));
|
||||
|
||||
/*!
|
||||
* @function dispatch_io_create_f
|
||||
* Create a dispatch I/O channel associated with a file descriptor. The system
|
||||
* takes control of the file descriptor until the channel is closed, an error
|
||||
* occurs on the file descriptor or all references to the channel are released.
|
||||
* At that time the specified cleanup handler will be enqueued and control over
|
||||
* the file descriptor relinquished.
|
||||
*
|
||||
* While a file descriptor is under the control of a dispatch I/O channel, file
|
||||
* descriptor flags such as O_NONBLOCK will be modified by the system on behalf
|
||||
* of the application. It is an error for the application to modify a file
|
||||
* descriptor directly while it is under the control of a dispatch I/O channel,
|
||||
* but it may create additional channels associated with that file descriptor.
|
||||
*
|
||||
* @param type The desired type of I/O channel (DISPATCH_IO_STREAM
|
||||
* or DISPATCH_IO_RANDOM).
|
||||
* @param fd The file descriptor to associate with the I/O channel.
|
||||
* @param queue The dispatch queue to which the handler should be submitted.
|
||||
* @param context The application-defined context parameter to pass to
|
||||
* the cleanup handler function.
|
||||
* @param cleanup_handler The handler to enqueue when the system
|
||||
* relinquishes control over the file descriptor.
|
||||
* param context Application-defined context parameter.
|
||||
* param error An errno condition if control is relinquished
|
||||
* because channel creation failed, zero otherwise.
|
||||
* @result The newly created dispatch I/O channel or NULL if an error
|
||||
* occurred (invalid type specified).
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
|
||||
DISPATCH_NOTHROW
|
||||
dispatch_io_t
|
||||
dispatch_io_create_f(dispatch_io_type_t type,
|
||||
dispatch_fd_t fd,
|
||||
dispatch_queue_t queue,
|
||||
void *_Nullable context,
|
||||
void (*cleanup_handler)(void *_Nullable context, int error));
|
||||
|
||||
/*!
|
||||
* @function dispatch_io_create_with_path_f
|
||||
* Create a dispatch I/O channel associated with a path name. The specified
|
||||
* path, oflag and mode parameters will be passed to open(2) when the first I/O
|
||||
* operation on the channel is ready to execute and the resulting file
|
||||
* descriptor will remain open and under the control of the system until the
|
||||
* channel is closed, an error occurs on the file descriptor or all references
|
||||
* to the channel are released. At that time the file descriptor will be closed
|
||||
* and the specified cleanup handler will be enqueued.
|
||||
*
|
||||
* @param type The desired type of I/O channel (DISPATCH_IO_STREAM
|
||||
* or DISPATCH_IO_RANDOM).
|
||||
* @param path The absolute path to associate with the I/O channel.
|
||||
* @param oflag The flags to pass to open(2) when opening the file at
|
||||
* path.
|
||||
* @param mode The mode to pass to open(2) when creating the file at
|
||||
* path (i.e. with flag O_CREAT), zero otherwise.
|
||||
* @param queue The dispatch queue to which the handler should be
|
||||
* submitted.
|
||||
* @param context The application-defined context parameter to pass to
|
||||
* the cleanup handler function.
|
||||
* @param cleanup_handler The handler to enqueue when the system
|
||||
* has closed the file at path.
|
||||
* param context Application-defined context parameter.
|
||||
* param error An errno condition if control is relinquished
|
||||
* because channel creation or opening of the
|
||||
* specified file failed, zero otherwise.
|
||||
* @result The newly created dispatch I/O channel or NULL if an error
|
||||
* occurred (invalid type or non-absolute path specified).
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED
|
||||
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
|
||||
dispatch_io_t
|
||||
dispatch_io_create_with_path_f(dispatch_io_type_t type,
|
||||
const char *path, int oflag, mode_t mode,
|
||||
dispatch_queue_t queue,
|
||||
void *_Nullable context,
|
||||
void (*cleanup_handler)(void *_Nullable context, int error));
|
||||
|
||||
/*!
|
||||
* @function dispatch_io_create_with_io_f
|
||||
* Create a new dispatch I/O channel from an existing dispatch I/O channel.
|
||||
* The new channel inherits the file descriptor or path name associated with
|
||||
* the existing channel, but not its channel type or policies.
|
||||
*
|
||||
* If the existing channel is associated with a file descriptor, control by the
|
||||
* system over that file descriptor is extended until the new channel is also
|
||||
* closed, an error occurs on the file descriptor, or all references to both
|
||||
* channels are released. At that time the specified cleanup handler will be
|
||||
* enqueued and control over the file descriptor relinquished.
|
||||
*
|
||||
* While a file descriptor is under the control of a dispatch I/O channel, file
|
||||
* descriptor flags such as O_NONBLOCK will be modified by the system on behalf
|
||||
* of the application. It is an error for the application to modify a file
|
||||
* descriptor directly while it is under the control of a dispatch I/O channel,
|
||||
* but it may create additional channels associated with that file descriptor.
|
||||
*
|
||||
* @param type The desired type of I/O channel (DISPATCH_IO_STREAM
|
||||
* or DISPATCH_IO_RANDOM).
|
||||
* @param io The existing channel to create the new I/O channel from.
|
||||
* @param queue The dispatch queue to which the handler should be submitted.
|
||||
* @param context The application-defined context parameter to pass to
|
||||
* the cleanup handler function.
|
||||
* @param cleanup_handler The handler to enqueue when the system
|
||||
* relinquishes control over the file descriptor
|
||||
* (resp. closes the file at path) associated with
|
||||
* the existing channel.
|
||||
* param context Application-defined context parameter.
|
||||
* param error An errno condition if control is relinquished
|
||||
* because channel creation failed, zero otherwise.
|
||||
* @result The newly created dispatch I/O channel or NULL if an error
|
||||
* occurred (invalid type specified).
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED
|
||||
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
|
||||
dispatch_io_t
|
||||
dispatch_io_create_with_io_f(dispatch_io_type_t type,
|
||||
dispatch_io_t io,
|
||||
dispatch_queue_t queue,
|
||||
void *_Nullable context,
|
||||
void (*cleanup_handler)(void *_Nullable context, int error));
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_io_handler_function_t
|
||||
* The prototype of I/O handler functions for dispatch I/O operations.
|
||||
*
|
||||
* @param context Application-defined context parameter.
|
||||
* @param done A flag indicating whether the operation is complete.
|
||||
* @param data The data object to be handled.
|
||||
* @param error An errno condition for the operation.
|
||||
*/
|
||||
typedef void (*dispatch_io_handler_function_t)(void *_Nullable context,
|
||||
bool done, dispatch_data_t _Nullable data, int error);
|
||||
|
||||
/*!
|
||||
* @function dispatch_io_read_f
|
||||
* Schedule a read operation for asynchronous execution on the specified I/O
|
||||
* channel. The I/O handler is enqueued one or more times depending on the
|
||||
* general load of the system and the policy specified on the I/O channel.
|
||||
*
|
||||
* Any data read from the channel is described by the dispatch data object
|
||||
* passed to the I/O handler. This object will be automatically released by the
|
||||
* system when the I/O handler returns. It is the responsibility of the
|
||||
* application to retain, concatenate or copy the data object if it is needed
|
||||
* after the I/O handler returns.
|
||||
*
|
||||
* Dispatch I/O handlers are not reentrant. The system will ensure that no new
|
||||
* I/O handler instance is invoked until the previously enqueued handler
|
||||
* function has returned.
|
||||
*
|
||||
* An invocation of the I/O handler with the done flag set indicates that the
|
||||
* read operation is complete and that the handler will not be enqueued again.
|
||||
*
|
||||
* If an unrecoverable error occurs on the I/O channel's underlying file
|
||||
* descriptor, the I/O handler will be enqueued with the done flag set, the
|
||||
* appropriate error code and a NULL data object.
|
||||
*
|
||||
* An invocation of the I/O handler with the done flag set, an error code of
|
||||
* zero and an empty data object indicates that EOF was reached.
|
||||
*
|
||||
* @param channel The dispatch I/O channel from which to read the data.
|
||||
* @param offset The offset relative to the channel position from which
|
||||
* to start reading (only for DISPATCH_IO_RANDOM).
|
||||
* @param length The length of data to read from the I/O channel, or
|
||||
* SIZE_MAX to indicate that data should be read until EOF
|
||||
* is reached.
|
||||
* @param queue The dispatch queue to which the I/O handler should be
|
||||
* submitted.
|
||||
* @param context The application-defined context parameter to pass to
|
||||
* the handler function.
|
||||
* @param io_handler The I/O handler to enqueue when data is ready to be
|
||||
* delivered.
|
||||
* param context Application-defined context parameter.
|
||||
* param done A flag indicating whether the operation is complete.
|
||||
* param data An object with the data most recently read from the
|
||||
* I/O channel as part of this read operation, or NULL.
|
||||
* param error An errno condition for the read operation or zero if
|
||||
* the read was successful.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL4 DISPATCH_NONNULL6
|
||||
DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_io_read_f(dispatch_io_t channel,
|
||||
off_t offset,
|
||||
size_t length,
|
||||
dispatch_queue_t queue,
|
||||
void *_Nullable context,
|
||||
dispatch_io_handler_function_t io_handler);
|
||||
|
||||
/*!
|
||||
* @function dispatch_io_write_f
|
||||
* Schedule a write operation for asynchronous execution on the specified I/O
|
||||
* channel. The I/O handler is enqueued one or more times depending on the
|
||||
* general load of the system and the policy specified on the I/O channel.
|
||||
*
|
||||
* Any data remaining to be written to the I/O channel is described by the
|
||||
* dispatch data object passed to the I/O handler. This object will be
|
||||
* automatically released by the system when the I/O handler returns. It is the
|
||||
* responsibility of the application to retain, concatenate or copy the data
|
||||
* object if it is needed after the I/O handler returns.
|
||||
*
|
||||
* Dispatch I/O handlers are not reentrant. The system will ensure that no new
|
||||
* I/O handler instance is invoked until the previously enqueued handler
|
||||
* function has returned.
|
||||
*
|
||||
* An invocation of the I/O handler with the done flag set indicates that the
|
||||
* write operation is complete and that the handler will not be enqueued again.
|
||||
*
|
||||
* If an unrecoverable error occurs on the I/O channel's underlying file
|
||||
* descriptor, the I/O handler will be enqueued with the done flag set, the
|
||||
* appropriate error code and an object containing the data that could not be
|
||||
* written.
|
||||
*
|
||||
* An invocation of the I/O handler with the done flag set and an error code of
|
||||
* zero indicates that the data was fully written to the channel.
|
||||
*
|
||||
* @param channel The dispatch I/O channel on which to write the data.
|
||||
* @param offset The offset relative to the channel position from which
|
||||
* to start writing (only for DISPATCH_IO_RANDOM).
|
||||
* @param data The data to write to the I/O channel. The data object
|
||||
* will be retained by the system until the write operation
|
||||
* is complete.
|
||||
* @param queue The dispatch queue to which the I/O handler should be
|
||||
* submitted.
|
||||
* @param context The application-defined context parameter to pass to
|
||||
* the handler function.
|
||||
* @param io_handler The I/O handler to enqueue when data has been delivered.
|
||||
* param context Application-defined context parameter.
|
||||
* param done A flag indicating whether the operation is complete.
|
||||
* param data An object of the data remaining to be
|
||||
* written to the I/O channel as part of this write
|
||||
* operation, or NULL.
|
||||
* param error An errno condition for the write operation or zero
|
||||
* if the write was successful.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NONNULL4
|
||||
DISPATCH_NONNULL6 DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_io_write_f(dispatch_io_t channel,
|
||||
off_t offset,
|
||||
dispatch_data_t data,
|
||||
dispatch_queue_t queue,
|
||||
void *_Nullable context,
|
||||
dispatch_io_handler_function_t io_handler);
|
||||
|
||||
/*!
|
||||
* @function dispatch_io_barrier_f
|
||||
* Schedule a barrier operation on the specified I/O channel; all previously
|
||||
* scheduled operations on the channel will complete before the provided
|
||||
* barrier function is enqueued onto the global queue determined by the
|
||||
* channel's target queue, and no subsequently scheduled operations will start
|
||||
* until the barrier function has returned.
|
||||
*
|
||||
* If multiple channels are associated with the same file descriptor, a barrier
|
||||
* operation scheduled on any of these channels will act as a barrier across all
|
||||
* channels in question, i.e. all previously scheduled operations on any of the
|
||||
* channels will complete before the barrier function is enqueued, and no
|
||||
* operations subsequently scheduled on any of the channels will start until the
|
||||
* barrier function has returned.
|
||||
*
|
||||
* While the barrier function is running, it may safely operate on the channel's
|
||||
* underlying file descriptor with fsync(2), lseek(2) etc. (but not close(2)).
|
||||
*
|
||||
* @param channel The dispatch I/O channel to schedule the barrier on.
|
||||
* @param context The application-defined context parameter to pass to
|
||||
* the barrier function.
|
||||
* @param barrier The barrier function.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_io_barrier_f(dispatch_io_t channel,
|
||||
void *_Nullable context,
|
||||
dispatch_function_t barrier);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_END
|
||||
|
||||
#endif /* __DISPATCH_IO_PRIVATE__ */
|
||||
101
Telegram/ThirdParty/dispatch/private/layout_private.h
vendored
Normal file
101
Telegram/ThirdParty/dispatch/private/layout_private.h
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __DISPATCH_LAYOUT_PRIVATE__
|
||||
#define __DISPATCH_LAYOUT_PRIVATE__
|
||||
|
||||
#ifndef __DISPATCH_INDIRECT__
|
||||
#error "Please #include <dispatch/private.h> instead of this file directly."
|
||||
#include <dispatch/base.h> // for HeaderDoc
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
API_AVAILABLE(macos(10.6), ios(4.0))
|
||||
DISPATCH_EXPORT const struct dispatch_queue_offsets_s {
|
||||
// always add new fields at the end
|
||||
const uint16_t dqo_version;
|
||||
const uint16_t dqo_label;
|
||||
const uint16_t dqo_label_size;
|
||||
const uint16_t dqo_flags;
|
||||
const uint16_t dqo_flags_size;
|
||||
const uint16_t dqo_serialnum;
|
||||
const uint16_t dqo_serialnum_size;
|
||||
const uint16_t dqo_width;
|
||||
const uint16_t dqo_width_size;
|
||||
const uint16_t dqo_running;
|
||||
const uint16_t dqo_running_size;
|
||||
// fields added in dqo_version 5:
|
||||
const uint16_t dqo_suspend_cnt;
|
||||
const uint16_t dqo_suspend_cnt_size;
|
||||
const uint16_t dqo_target_queue;
|
||||
const uint16_t dqo_target_queue_size;
|
||||
const uint16_t dqo_priority;
|
||||
const uint16_t dqo_priority_size;
|
||||
} dispatch_queue_offsets;
|
||||
|
||||
#if DISPATCH_LAYOUT_SPI
|
||||
/*!
|
||||
* @group Data Structure Layout SPI
|
||||
* SPI intended for CoreSymbolication only
|
||||
*/
|
||||
|
||||
API_AVAILABLE(macos(10.10), ios(8.0))
|
||||
DISPATCH_EXPORT const struct dispatch_tsd_indexes_s {
|
||||
// always add new fields at the end
|
||||
const uint16_t dti_version;
|
||||
const uint16_t dti_queue_index;
|
||||
const uint16_t dti_voucher_index;
|
||||
const uint16_t dti_qos_class_index;
|
||||
/* version 3 */
|
||||
const uint16_t dti_continuation_cache_index;
|
||||
} dispatch_tsd_indexes;
|
||||
|
||||
#if TARGET_OS_MAC
|
||||
|
||||
#include <malloc/malloc.h>
|
||||
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT const struct dispatch_allocator_layout_s {
|
||||
const uint16_t dal_version;
|
||||
/* version 1 */
|
||||
/* Pointer to the allocator metadata address, points to NULL if unused */
|
||||
void **const dal_allocator_zone;
|
||||
/* Magical "isa" for allocations that are on freelists */
|
||||
void *const *const dal_deferred_free_isa;
|
||||
/* Size of allocations made in the magazine */
|
||||
const uint16_t dal_allocation_size;
|
||||
/* fields used by the enumerator */
|
||||
const uint16_t dal_magazine_size;
|
||||
const uint16_t dal_first_allocation_offset;
|
||||
const uint16_t dal_allocation_isa_offset;
|
||||
/* Enumerates allocated continuations */
|
||||
kern_return_t (*dal_enumerator)(task_t remote_task,
|
||||
const struct dispatch_allocator_layout_s *remote_allocator_layout,
|
||||
vm_address_t zone_address, memory_reader_t reader,
|
||||
void (^recorder)(vm_address_t dc_address, void *dc_mem,
|
||||
size_t size, bool *stop));
|
||||
} dispatch_allocator_layout;
|
||||
#endif // TARGET_OS_MAC
|
||||
#endif // DISPATCH_LAYOUT_SPI
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // __DISPATCH_LAYOUT_PRIVATE__
|
||||
1155
Telegram/ThirdParty/dispatch/private/mach_private.h
vendored
Normal file
1155
Telegram/ThirdParty/dispatch/private/mach_private.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
269
Telegram/ThirdParty/dispatch/private/private.h
vendored
Normal file
269
Telegram/ThirdParty/dispatch/private/private.h
vendored
Normal file
@@ -0,0 +1,269 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2013 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
* IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
|
||||
* which are subject to change in future releases of Mac OS X. Any applications
|
||||
* relying on these interfaces WILL break.
|
||||
*/
|
||||
|
||||
#ifndef __DISPATCH_PRIVATE__
|
||||
#define __DISPATCH_PRIVATE__
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <Availability.h>
|
||||
#include <os/availability.h>
|
||||
#include <TargetConditionals.h>
|
||||
#include <os/base.h>
|
||||
#elif defined(_WIN32)
|
||||
#include <os/generic_win_base.h>
|
||||
#elif defined(__unix__)
|
||||
#include <os/generic_unix_base.h>
|
||||
#endif
|
||||
|
||||
#if TARGET_OS_MAC
|
||||
#include <mach/boolean.h>
|
||||
#include <mach/mach.h>
|
||||
#include <mach/message.h>
|
||||
#endif
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if !defined(_WIN32)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#if TARGET_OS_MAC
|
||||
#include <pthread/qos.h>
|
||||
#endif
|
||||
|
||||
#ifndef __DISPATCH_BUILDING_DISPATCH__
|
||||
#include <dispatch/dispatch.h>
|
||||
|
||||
#ifndef __DISPATCH_INDIRECT__
|
||||
#define __DISPATCH_INDIRECT__
|
||||
#endif
|
||||
|
||||
#include <dispatch/benchmark.h>
|
||||
#include <dispatch/queue_private.h>
|
||||
#include <dispatch/workloop_private.h>
|
||||
#include <dispatch/source_private.h>
|
||||
#if DISPATCH_MACH_SPI
|
||||
#include <dispatch/mach_private.h>
|
||||
#endif // DISPATCH_MACH_SPI
|
||||
#include <dispatch/data_private.h>
|
||||
#include <dispatch/io_private.h>
|
||||
#include <dispatch/layout_private.h>
|
||||
#include <dispatch/time_private.h>
|
||||
|
||||
#undef __DISPATCH_INDIRECT__
|
||||
#endif /* !__DISPATCH_BUILDING_DISPATCH__ */
|
||||
|
||||
// <rdar://problem/9627726> Check that public and private dispatch headers match
|
||||
#if DISPATCH_API_VERSION != 20180109 // Keep in sync with <dispatch/dispatch.h>
|
||||
#error "Dispatch header mismatch between /usr/include and /usr/local/include"
|
||||
#endif
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_BEGIN
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*!
|
||||
* @function _dispatch_is_multithreaded
|
||||
*
|
||||
* @abstract
|
||||
* Returns true if the current process has become multithreaded by the use
|
||||
* of libdispatch functionality.
|
||||
*
|
||||
* @discussion
|
||||
* This SPI is intended for use by low-level system components that need to
|
||||
* ensure that they do not make a single-threaded process multithreaded, to
|
||||
* avoid negatively affecting child processes of a fork (without exec).
|
||||
*
|
||||
* Such components must not use any libdispatch functionality if this function
|
||||
* returns false.
|
||||
*
|
||||
* @result
|
||||
* Boolean indicating whether the process has used libdispatch and become
|
||||
* multithreaded.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.8), ios(6.0))
|
||||
DISPATCH_EXPORT DISPATCH_NOTHROW
|
||||
bool _dispatch_is_multithreaded(void);
|
||||
|
||||
/*!
|
||||
* @function _dispatch_is_fork_of_multithreaded_parent
|
||||
*
|
||||
* @abstract
|
||||
* Returns true if the current process is a child of a parent process that had
|
||||
* become multithreaded by the use of libdispatch functionality at the time of
|
||||
* fork (without exec).
|
||||
*
|
||||
* @discussion
|
||||
* This SPI is intended for use by (rare) low-level system components that need
|
||||
* to continue working on the child side of a fork (without exec) of a
|
||||
* multithreaded process.
|
||||
*
|
||||
* Such components must not use any libdispatch functionality if this function
|
||||
* returns true.
|
||||
*
|
||||
* @result
|
||||
* Boolean indicating whether the parent process had used libdispatch and
|
||||
* become multithreaded at the time of fork.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_NOTHROW
|
||||
bool _dispatch_is_fork_of_multithreaded_parent(void);
|
||||
|
||||
/*!
|
||||
* @function _dispatch_prohibit_transition_to_multithreaded
|
||||
*
|
||||
* @abstract
|
||||
* Sets a mode that aborts if a program tries to use dispatch.
|
||||
*
|
||||
* @discussion
|
||||
* This SPI is intended for use by programs that know they will use fork() and
|
||||
* want their children to be able to use dispatch before exec(). Such programs
|
||||
* should call _dispatch_prohibit_transition_to_multithreaded(true) as early as
|
||||
* possible, which will cause any use of dispatch API that would make the
|
||||
* process multithreaded to abort immediately.
|
||||
*
|
||||
* Once the program no longer intends to call fork() it can call
|
||||
* _dispatch_prohibit_transition_to_multithreaded(false).
|
||||
*
|
||||
* This status is not inherited by the child process, so if the behavior
|
||||
* is required after fork, _dispatch_prohibit_transition_to_multithreaded(true)
|
||||
* should be called manually in the child after fork.
|
||||
*
|
||||
* If the program already used dispatch before the guard is enabled, then
|
||||
* this function will abort immediately.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
|
||||
DISPATCH_EXPORT DISPATCH_NOTHROW
|
||||
void _dispatch_prohibit_transition_to_multithreaded(bool prohibit);
|
||||
|
||||
/*
|
||||
* dispatch_time convenience macros
|
||||
*/
|
||||
|
||||
#define _dispatch_time_after_nsec(t) \
|
||||
dispatch_time(DISPATCH_TIME_NOW, (t))
|
||||
#define _dispatch_time_after_usec(t) \
|
||||
dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_USEC)
|
||||
#define _dispatch_time_after_msec(t) \
|
||||
dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_MSEC)
|
||||
#define _dispatch_time_after_sec(t) \
|
||||
dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_SEC)
|
||||
|
||||
/*
|
||||
* SPI for CoreFoundation/Foundation ONLY
|
||||
*/
|
||||
|
||||
#if TARGET_OS_MAC
|
||||
#define DISPATCH_COCOA_COMPAT 1
|
||||
#elif defined(__linux__) || defined(__FreeBSD__) || defined(_WIN32)
|
||||
#define DISPATCH_COCOA_COMPAT 1
|
||||
#else
|
||||
#define DISPATCH_COCOA_COMPAT 0
|
||||
#endif
|
||||
|
||||
#if DISPATCH_COCOA_COMPAT
|
||||
|
||||
#define DISPATCH_CF_SPI_VERSION 20160712
|
||||
|
||||
#if TARGET_OS_MAC
|
||||
typedef mach_port_t dispatch_runloop_handle_t;
|
||||
#elif defined(__linux__) || defined(__FreeBSD__)
|
||||
typedef int dispatch_runloop_handle_t;
|
||||
#elif defined(_WIN32)
|
||||
typedef void *dispatch_runloop_handle_t;
|
||||
#else
|
||||
#error "runloop support not implemented on this platform"
|
||||
#endif
|
||||
|
||||
API_AVAILABLE(macos(10.6), ios(4.0))
|
||||
DISPATCH_EXPORT DISPATCH_CONST DISPATCH_WARN_RESULT DISPATCH_NOTHROW
|
||||
dispatch_runloop_handle_t
|
||||
_dispatch_get_main_queue_port_4CF(void);
|
||||
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
|
||||
DISPATCH_EXPORT DISPATCH_NOTHROW
|
||||
dispatch_runloop_handle_t
|
||||
_dispatch_get_main_queue_handle_4CF(void);
|
||||
|
||||
API_AVAILABLE(macos(10.6), ios(4.0))
|
||||
DISPATCH_EXPORT DISPATCH_NOTHROW
|
||||
void
|
||||
_dispatch_main_queue_callback_4CF(void *_Null_unspecified msg);
|
||||
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
|
||||
DISPATCH_NOTHROW
|
||||
dispatch_queue_serial_t
|
||||
_dispatch_runloop_root_queue_create_4CF(const char *_Nullable label,
|
||||
unsigned long flags);
|
||||
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW
|
||||
dispatch_runloop_handle_t
|
||||
_dispatch_runloop_root_queue_get_port_4CF(dispatch_queue_t queue);
|
||||
|
||||
#if TARGET_OS_MAC
|
||||
API_AVAILABLE(macos(10.13.2), ios(11.2), tvos(11.2), watchos(4.2))
|
||||
DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW
|
||||
bool
|
||||
_dispatch_source_will_reenable_kevent_4NW(dispatch_source_t source);
|
||||
#endif
|
||||
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_NOTHROW
|
||||
void
|
||||
_dispatch_runloop_root_queue_wakeup_4CF(dispatch_queue_t queue);
|
||||
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW
|
||||
bool
|
||||
_dispatch_runloop_root_queue_perform_4CF(dispatch_queue_t queue);
|
||||
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
void
|
||||
_dispatch_source_set_runloop_timer_4CF(dispatch_source_t source,
|
||||
dispatch_time_t start, uint64_t interval, uint64_t leeway);
|
||||
|
||||
API_AVAILABLE(macos(10.6), ios(4.0))
|
||||
DISPATCH_EXPORT
|
||||
void *_Nonnull (*_Nullable _dispatch_begin_NSAutoReleasePool)(void);
|
||||
|
||||
API_AVAILABLE(macos(10.6), ios(4.0))
|
||||
DISPATCH_EXPORT
|
||||
void (*_Nullable _dispatch_end_NSAutoReleasePool)(void *);
|
||||
|
||||
#endif /* DISPATCH_COCOA_COMPAT */
|
||||
|
||||
API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
|
||||
DISPATCH_EXPORT DISPATCH_NOTHROW
|
||||
void
|
||||
_dispatch_poll_for_events_4launchd(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_END
|
||||
|
||||
#endif // __DISPATCH_PRIVATE__
|
||||
503
Telegram/ThirdParty/dispatch/private/queue_private.h
vendored
Normal file
503
Telegram/ThirdParty/dispatch/private/queue_private.h
vendored
Normal file
@@ -0,0 +1,503 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2013 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
* IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
|
||||
* which are subject to change in future releases of Mac OS X. Any applications
|
||||
* relying on these interfaces WILL break.
|
||||
*/
|
||||
|
||||
#ifndef __DISPATCH_QUEUE_PRIVATE__
|
||||
#define __DISPATCH_QUEUE_PRIVATE__
|
||||
|
||||
#ifndef __DISPATCH_INDIRECT__
|
||||
#error "Please #include <dispatch/private.h> instead of this file directly."
|
||||
#include <dispatch/base.h> // for HeaderDoc
|
||||
#endif
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_BEGIN
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*!
|
||||
* @enum dispatch_queue_flags_t
|
||||
*
|
||||
* @constant DISPATCH_QUEUE_OVERCOMMIT
|
||||
* The queue will create a new thread for invoking blocks, regardless of how
|
||||
* busy the computer is.
|
||||
*/
|
||||
enum {
|
||||
DISPATCH_QUEUE_OVERCOMMIT = 0x2ull,
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* @function dispatch_set_qos_class
|
||||
*
|
||||
* @abstract
|
||||
* Sets the QOS class on a dispatch queue, source or mach channel.
|
||||
*
|
||||
* @discussion
|
||||
* This is equivalent to using dispatch_queue_make_attr_with_qos_class()
|
||||
* when creating a dispatch queue, but is availabile on additional dispatch
|
||||
* object types.
|
||||
*
|
||||
* When configured in this manner, the specified QOS class will be used over
|
||||
* the assigned QOS of workitems submitted asynchronously to this object,
|
||||
* unless the workitem has been created with ENFORCE semantics
|
||||
* (see DISPATCH_BLOCK_ENFORCE_QOS_CLASS).
|
||||
*
|
||||
* Calling this function will supersede any prior calls to
|
||||
* dispatch_set_qos_class() or dispatch_set_qos_class_floor().
|
||||
*
|
||||
* @param object
|
||||
* A dispatch queue, source or mach channel to configure.
|
||||
* The object must be inactive, and can't be a workloop.
|
||||
*
|
||||
* Passing another object type or an object that has been activated is undefined
|
||||
* and will cause the process to be terminated.
|
||||
*
|
||||
* @param qos_class
|
||||
* A QOS class value:
|
||||
* - QOS_CLASS_USER_INTERACTIVE
|
||||
* - QOS_CLASS_USER_INITIATED
|
||||
* - QOS_CLASS_DEFAULT
|
||||
* - QOS_CLASS_UTILITY
|
||||
* - QOS_CLASS_BACKGROUND
|
||||
* Passing any other value is undefined.
|
||||
*
|
||||
* @param relative_priority
|
||||
* A relative priority within the QOS class. This value is a negative
|
||||
* offset from the maximum supported scheduler priority for the given class.
|
||||
* Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY
|
||||
* is undefined.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_set_qos_class(dispatch_object_t object,
|
||||
dispatch_qos_class_t qos_class, int relative_priority);
|
||||
|
||||
/*!
|
||||
* @function dispatch_set_qos_class_floor
|
||||
*
|
||||
* @abstract
|
||||
* Sets the QOS class floor on a dispatch queue, source, workloop or mach
|
||||
* channel.
|
||||
*
|
||||
* @discussion
|
||||
* The QOS class of workitems submitted to this object asynchronously will be
|
||||
* elevated to at least the specified QOS class floor.
|
||||
* Unlike dispatch_set_qos_class(), the QOS of the workitem will be used if
|
||||
* higher than the floor even when the workitem has been created without
|
||||
* "ENFORCE" semantics.
|
||||
*
|
||||
* Setting the QOS class floor is equivalent to the QOS effects of configuring
|
||||
* a target queue whose QOS class has been set with dispatch_set_qos_class().
|
||||
*
|
||||
* Calling this function will supersede any prior calls to
|
||||
* dispatch_set_qos_class() or dispatch_set_qos_class_floor().
|
||||
*
|
||||
* @param object
|
||||
* A dispatch queue, workloop, source or mach channel to configure.
|
||||
* The object must be inactive.
|
||||
*
|
||||
* Passing another object type or an object that has been activated is undefined
|
||||
* and will cause the process to be terminated.
|
||||
*
|
||||
* @param qos_class
|
||||
* A QOS class value:
|
||||
* - QOS_CLASS_USER_INTERACTIVE
|
||||
* - QOS_CLASS_USER_INITIATED
|
||||
* - QOS_CLASS_DEFAULT
|
||||
* - QOS_CLASS_UTILITY
|
||||
* - QOS_CLASS_BACKGROUND
|
||||
* Passing any other value is undefined.
|
||||
*
|
||||
* @param relative_priority
|
||||
* A relative priority within the QOS class. This value is a negative
|
||||
* offset from the maximum supported scheduler priority for the given class.
|
||||
* Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY
|
||||
* is undefined.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_set_qos_class_floor(dispatch_object_t object,
|
||||
dispatch_qos_class_t qos_class, int relative_priority);
|
||||
|
||||
/*!
|
||||
* @function dispatch_set_qos_class_fallback
|
||||
*
|
||||
* @abstract
|
||||
* Sets the fallback QOS class on a dispatch queue, source, workloop or mach
|
||||
* channel.
|
||||
*
|
||||
* @discussion
|
||||
* Workitems submitted asynchronously to this object that don't have an assigned
|
||||
* QOS class will use the specified QOS class as a fallback. This interface
|
||||
* doesn't support relative priority.
|
||||
*
|
||||
* Workitems without an assigned QOS are:
|
||||
* - workitems submitted from the context of a thread opted-out of QOS,
|
||||
* - workitems created with the DISPATCH_BLOCK_DETACHED or
|
||||
* DISPATCH_BLOCK_NO_QOS_CLASS flags,
|
||||
* - XPC messages sent with xpc_connection_send_notification(),
|
||||
* - XPC connection and dispatch source handlers.
|
||||
*
|
||||
* Calling both dispatch_set_qos_class_fallback() and dispatch_set_qos_class()
|
||||
* on an object will only apply the effect of dispatch_set_qos_class().
|
||||
*
|
||||
* A QOS class fallback must always be at least as high as the current QOS
|
||||
* floor for the dispatch queue hierarchy, else it is ignored.
|
||||
*
|
||||
* When no QOS fallback has been explicitly specified:
|
||||
* - queues on hierarchies without a QOS class or QOS class floor have
|
||||
* a fallback of QOS_CLASS_DEFAULT,
|
||||
* - queues on hierarchies with a QOS class or QOS class floor configured will
|
||||
* also use that QOS class as a fallback.
|
||||
*
|
||||
* @param object
|
||||
* A dispatch queue, workloop, source or mach channel to configure.
|
||||
* The object must be inactive.
|
||||
*
|
||||
* Passing another object type or an object that has been activated is undefined
|
||||
* and will cause the process to be terminated.
|
||||
*
|
||||
* @param qos_class
|
||||
* A QOS class value:
|
||||
* - QOS_CLASS_USER_INTERACTIVE
|
||||
* - QOS_CLASS_USER_INITIATED
|
||||
* - QOS_CLASS_DEFAULT
|
||||
* - QOS_CLASS_UTILITY
|
||||
* - QOS_CLASS_BACKGROUND
|
||||
* Passing any other value is undefined.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_set_qos_class_fallback(dispatch_object_t object,
|
||||
dispatch_qos_class_t qos_class);
|
||||
|
||||
#define DISPATCH_QUEUE_FLAGS_MASK (DISPATCH_QUEUE_OVERCOMMIT)
|
||||
|
||||
// On FreeBSD pthread_attr_t is a typedef to a pointer type
|
||||
#if defined(__FreeBSD__)
|
||||
# define DISPATCH_QUEUE_NULLABLE_PTHREAD_ATTR_PTR _Nullable
|
||||
#else
|
||||
# define DISPATCH_QUEUE_NULLABLE_PTHREAD_ATTR_PTR
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @function dispatch_queue_attr_make_with_overcommit
|
||||
*
|
||||
* @discussion
|
||||
* Returns a dispatch queue attribute value with the overcommit flag set to the
|
||||
* specified value.
|
||||
*
|
||||
* This attribute only makes sense when the specified queue is targeted at
|
||||
* a root queue. Passing this attribute to dispatch_queue_create_with_target()
|
||||
* with a target queue that is not a root queue will result in an assertion and
|
||||
* the process being terminated.
|
||||
*
|
||||
* It is recommended to not specify a target queue at all when using this
|
||||
* attribute and to use dispatch_queue_attr_make_with_qos_class() to select the
|
||||
* appropriate QOS class instead.
|
||||
*
|
||||
* Queues created with this attribute cannot change target after having been
|
||||
* activated. See dispatch_set_target_queue() and dispatch_activate().
|
||||
*
|
||||
* @param attr
|
||||
* A queue attribute value to be combined with the overcommit flag, or NULL.
|
||||
*
|
||||
* @param overcommit
|
||||
* Boolean overcommit flag.
|
||||
*
|
||||
* @return
|
||||
* Returns an attribute value which may be provided to dispatch_queue_create().
|
||||
* This new value combines the attributes specified by the 'attr' parameter and
|
||||
* the overcommit flag.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.10), ios(8.0))
|
||||
DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_PURE DISPATCH_NOTHROW
|
||||
dispatch_queue_attr_t
|
||||
dispatch_queue_attr_make_with_overcommit(dispatch_queue_attr_t _Nullable attr,
|
||||
bool overcommit);
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_queue_priority_t
|
||||
*
|
||||
* @constant DISPATCH_QUEUE_PRIORITY_NON_INTERACTIVE
|
||||
* Items dispatched to the queue will run at non-interactive priority.
|
||||
* This priority level is intended for user-initiated application activity that
|
||||
* is long-running and CPU or IO intensive and that the user is actively waiting
|
||||
* on, but that should not interfere with interactive use of the application.
|
||||
*
|
||||
* This global queue priority level is mapped to QOS_CLASS_UTILITY.
|
||||
*/
|
||||
#define DISPATCH_QUEUE_PRIORITY_NON_INTERACTIVE INT8_MIN
|
||||
|
||||
/*!
|
||||
* @function dispatch_queue_set_label_nocopy
|
||||
*
|
||||
* @abstract
|
||||
* Set the label for a given queue, without copying the input string.
|
||||
*
|
||||
* @discussion
|
||||
* The queue must have been initially created with a NULL label, else using
|
||||
* this function to set the queue label is undefined.
|
||||
*
|
||||
* The caller of this function must make sure the label pointer remains valid
|
||||
* while it is used as the queue label and while any callers to
|
||||
* dispatch_queue_get_label() may have obtained it. Since the queue lifetime
|
||||
* may extend past the last release, it is advised to call this function with
|
||||
* a constant string or NULL before the queue is released, or to destroy the
|
||||
* label from a finalizer for that queue.
|
||||
*
|
||||
* This function should be called before any work item could call
|
||||
* dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL) or from the context of
|
||||
* the queue itself.
|
||||
*
|
||||
* @param queue
|
||||
* The queue to adjust. Attempts to set the label of the main queue or a global
|
||||
* concurrent queue will be ignored.
|
||||
*
|
||||
* @param label
|
||||
* The new label for the queue.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_queue_set_label_nocopy(dispatch_queue_t queue,
|
||||
const char * _Nullable label);
|
||||
|
||||
/*!
|
||||
* @function dispatch_queue_set_width
|
||||
*
|
||||
* @abstract
|
||||
* Set the width of concurrency for a given queue. The width of a serial queue
|
||||
* is one.
|
||||
*
|
||||
* @discussion
|
||||
* This SPI is DEPRECATED and will be removed in a future release.
|
||||
* Uses of this SPI to make a queue concurrent by setting its width to LONG_MAX
|
||||
* should be replaced by passing DISPATCH_QUEUE_CONCURRENT to
|
||||
* dispatch_queue_create().
|
||||
* Uses of this SPI to limit queue concurrency are not recommended and should
|
||||
* be replaced by alternative mechanisms such as a dispatch semaphore created
|
||||
* with the desired concurrency width.
|
||||
*
|
||||
* @param queue
|
||||
* The queue to adjust. Attempts to set the width of the main queue or a global
|
||||
* concurrent queue will be ignored.
|
||||
*
|
||||
* @param width
|
||||
* The new maximum width of concurrency depending on available resources.
|
||||
* If zero is passed, then the value is promoted to one.
|
||||
* Negative values are magic values that map to automatic width values.
|
||||
* Unknown negative values default to DISPATCH_QUEUE_WIDTH_MAX_LOGICAL_CPUS.
|
||||
*/
|
||||
#define DISPATCH_QUEUE_WIDTH_ACTIVE_CPUS -1
|
||||
#define DISPATCH_QUEUE_WIDTH_MAX_PHYSICAL_CPUS -2
|
||||
#define DISPATCH_QUEUE_WIDTH_MAX_LOGICAL_CPUS -3
|
||||
|
||||
API_DEPRECATED("Use dispatch_queue_create(name, DISPATCH_QUEUE_CONCURRENT)",
|
||||
macos(10.6,10.10), ios(4.0,8.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_queue_set_width(dispatch_queue_t dq, long width);
|
||||
|
||||
#if defined(__BLOCKS__) && defined(__APPLE__)
|
||||
/*!
|
||||
* @function dispatch_pthread_root_queue_create
|
||||
*
|
||||
* @abstract
|
||||
* Creates a new concurrent dispatch root queue with a pthread-based pool of
|
||||
* worker threads owned by the application.
|
||||
*
|
||||
* @discussion
|
||||
* Dispatch pthread root queues are similar to the global concurrent dispatch
|
||||
* queues in that they invoke blocks concurrently, however the blocks are not
|
||||
* executed on ordinary worker threads but use a dedicated pool of pthreads not
|
||||
* shared with the global queues or any other pthread root queues.
|
||||
*
|
||||
* NOTE: this is a special-purpose facility that should only be used in very
|
||||
* limited circumstances, in almost all cases the global concurrent queues
|
||||
* should be preferred. While this facility allows for more flexibility in
|
||||
* configuring worker threads for special needs it comes at the cost of
|
||||
* increased overall memory usage due to reduced thread sharing and higher
|
||||
* latency in worker thread bringup.
|
||||
*
|
||||
* Dispatch pthread root queues do not support suspension, application context
|
||||
* and change of width or of target queue. They can however be used as the
|
||||
* target queue for serial or concurrent queues obtained via
|
||||
* dispatch_queue_create() or dispatch_queue_create_with_target(), which
|
||||
* enables the blocks submitted to those queues to be processed on the root
|
||||
* queue's pthread pool.
|
||||
*
|
||||
* When a dispatch pthread root queue is no longer needed, it should be
|
||||
* released with dispatch_release(). Existing worker pthreads and pending blocks
|
||||
* submitted to the root queue will hold a reference to the queue so it will not
|
||||
* be deallocated until all blocks have finished and worker threads exited.
|
||||
*
|
||||
* @param label
|
||||
* A string label to attach to the queue.
|
||||
* This parameter is optional and may be NULL.
|
||||
*
|
||||
* @param flags
|
||||
* Pass flags value returned by dispatch_pthread_root_queue_flags_pool_size()
|
||||
* or 0 if unused.
|
||||
*
|
||||
* @param attr
|
||||
* Attributes passed to pthread_create(3) when creating worker pthreads. This
|
||||
* parameter is copied and can be destroyed after this call returns.
|
||||
* This parameter is optional and may be NULL.
|
||||
*
|
||||
* @param configure
|
||||
* Configuration block called on newly created worker pthreads before any blocks
|
||||
* for the root queue are executed. The block may configure the current thread
|
||||
* as needed.
|
||||
* This parameter is optional and may be NULL.
|
||||
*
|
||||
* @result
|
||||
* The newly created dispatch pthread root queue.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.9), ios(6.0)) DISPATCH_LINUX_UNAVAILABLE()
|
||||
DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
|
||||
DISPATCH_NOTHROW
|
||||
dispatch_queue_global_t
|
||||
dispatch_pthread_root_queue_create(const char *_Nullable label,
|
||||
unsigned long flags, const pthread_attr_t DISPATCH_QUEUE_NULLABLE_PTHREAD_ATTR_PTR *_Nullable attr,
|
||||
dispatch_block_t _Nullable configure);
|
||||
|
||||
/*!
|
||||
* @function dispatch_pthread_root_queue_flags_pool_size
|
||||
*
|
||||
* @abstract
|
||||
* Returns flags argument to pass to dispatch_pthread_root_queue_create() to
|
||||
* specify the maximum size of the pthread pool to use for a pthread root queue.
|
||||
*
|
||||
* @param pool_size
|
||||
* Maximum size of the pthread pool to use for the root queue. The number of
|
||||
* pthreads created for this root queue will never exceed this number but there
|
||||
* is no guarantee that the specified number will be reached.
|
||||
* Pass 0 to specify that a default pool size determined by the system should
|
||||
* be used.
|
||||
* NOTE: passing pool_size == 1 does NOT make the pthread root queue equivalent
|
||||
* to a serial queue.
|
||||
*
|
||||
* @result
|
||||
* The flags argument to pass to dispatch_pthread_root_queue_create().
|
||||
*/
|
||||
DISPATCH_INLINE DISPATCH_ALWAYS_INLINE
|
||||
unsigned long
|
||||
dispatch_pthread_root_queue_flags_pool_size(uint8_t pool_size)
|
||||
{
|
||||
#define _DISPATCH_PTHREAD_ROOT_QUEUE_FLAG_POOL_SIZE (0x80000000ul)
|
||||
return (_DISPATCH_PTHREAD_ROOT_QUEUE_FLAG_POOL_SIZE |
|
||||
(unsigned long)pool_size);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @function dispatch_pthread_root_queue_copy_current
|
||||
*
|
||||
* @abstract
|
||||
* Returns a reference to the pthread root queue object that has created the
|
||||
* currently executing thread, or NULL if the current thread is not associated
|
||||
* to a pthread root queue.
|
||||
*
|
||||
* @result
|
||||
* A new reference to a pthread root queue object or NULL.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
|
||||
DISPATCH_LINUX_UNAVAILABLE()
|
||||
DISPATCH_EXPORT DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT DISPATCH_NOTHROW
|
||||
dispatch_queue_global_t _Nullable
|
||||
dispatch_pthread_root_queue_copy_current(void);
|
||||
|
||||
/*!
|
||||
* @constant DISPATCH_APPLY_CURRENT_ROOT_QUEUE
|
||||
*
|
||||
* @discussion
|
||||
* This constant is deprecated, please use DISPATCH_APPLY_AUTO.
|
||||
*
|
||||
* DISPATCH_APPLY_AUTO also selects the current pthread root queue if
|
||||
* applicable.
|
||||
*/
|
||||
#define DISPATCH_APPLY_CURRENT_ROOT_QUEUE ((dispatch_queue_t _Nonnull)0)
|
||||
|
||||
#endif /* defined(__BLOCKS__) && defined(__APPLE__) */
|
||||
|
||||
/*!
|
||||
* @function dispatch_async_enforce_qos_class_f
|
||||
*
|
||||
* @abstract
|
||||
* Submits a function for asynchronous execution on a dispatch queue.
|
||||
*
|
||||
* @discussion
|
||||
* See dispatch_async() for details. The QOS will be enforced as if
|
||||
* this was called:
|
||||
* <code>
|
||||
* dispatch_async(queue, dispatch_block_create(DISPATCH_BLOCK_ENFORCE_QOS_CLASS, ^{
|
||||
* work(context);
|
||||
* });
|
||||
* </code>
|
||||
*
|
||||
* @param queue
|
||||
* The target dispatch queue to which the function is submitted.
|
||||
* The system will hold a reference on the target queue until the function
|
||||
* has returned.
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*
|
||||
* @param context
|
||||
* The application-defined context parameter to pass to the function.
|
||||
*
|
||||
* @param work
|
||||
* The application-defined function to invoke on the target queue. The first
|
||||
* parameter passed to this function is the context provided to
|
||||
* dispatch_async_f().
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.11), ios(9.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_async_enforce_qos_class_f(dispatch_queue_t queue,
|
||||
void *_Nullable context, dispatch_function_t work);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
/*!
|
||||
* @function _dispatch_install_thread_detach_callback
|
||||
*
|
||||
* @param cb
|
||||
* Function to be called before each worker thread exits to detach JVM.
|
||||
*
|
||||
* Hook to be able to detach threads from the Java JVM before they exit.
|
||||
* If JNI has been used on a thread on Android it needs to have been
|
||||
* "detached" before the thread exits or the application will crash.
|
||||
*/
|
||||
DISPATCH_EXPORT
|
||||
void _dispatch_install_thread_detach_callback(void (*cb)(void));
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
649
Telegram/ThirdParty/dispatch/private/source_private.h
vendored
Normal file
649
Telegram/ThirdParty/dispatch/private/source_private.h
vendored
Normal file
@@ -0,0 +1,649 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2013 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
* IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
|
||||
* which are subject to change in future releases of Mac OS X. Any applications
|
||||
* relying on these interfaces WILL break.
|
||||
*/
|
||||
|
||||
#ifndef __DISPATCH_SOURCE_PRIVATE__
|
||||
#define __DISPATCH_SOURCE_PRIVATE__
|
||||
|
||||
#ifndef __DISPATCH_INDIRECT__
|
||||
#error "Please #include <dispatch/private.h> instead of this file directly."
|
||||
#include <dispatch/base.h> // for HeaderDoc
|
||||
#endif
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_BEGIN
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_SOURCE_TYPE_INTERVAL
|
||||
* @discussion A dispatch source that submits the event handler block at a
|
||||
* specified time interval, phase-aligned with all other interval sources on
|
||||
* the system that have the same interval value.
|
||||
*
|
||||
* The initial submission of the event handler will occur at some point during
|
||||
* the first time interval after the source is created (assuming the source is
|
||||
* resumed at that time).
|
||||
*
|
||||
* By default, the unit for the interval value is milliseconds and the leeway
|
||||
* (maximum amount of time any individual handler submission may be deferred to
|
||||
* align with other system activity) for the source is fixed at interval/2.
|
||||
*
|
||||
* If the DISPATCH_INTERVAL_UI_ANIMATION flag is specified, the unit for the
|
||||
* interval value is animation frames (1/60th of a second) and the leeway is
|
||||
* fixed at one frame.
|
||||
*
|
||||
* The handle is the interval value in milliseconds or frames.
|
||||
* The mask specifies which flags from dispatch_source_timer_flags_t to apply.
|
||||
*
|
||||
* Starting with macOS 10.14, iOS 12, dispatch_source_set_timer()
|
||||
* can be used on such sources, and its arguments are used as follow:
|
||||
* - start:
|
||||
* must be DISPATCH_TIME_NOW or DISPATCH_TIME_FOREVER.
|
||||
* DISPATCH_TIME_NOW will enable the timer, and align its phase, and
|
||||
* DISPATCH_TIME_FOREVER will disable the timer as usual.*
|
||||
* - interval:
|
||||
* its unit is in milliseconds by default, or frames if the source
|
||||
* was created with the DISPATCH_INTERVAL_UI_ANIMATION flag.
|
||||
* - leeway:
|
||||
* per-thousands of the interval (valid values range from 0 to 1000).
|
||||
* If ~0ull is passed, the default leeway for the interval is used instead.
|
||||
*/
|
||||
#define DISPATCH_SOURCE_TYPE_INTERVAL (&_dispatch_source_type_interval)
|
||||
API_AVAILABLE(macos(10.9), ios(7.0))
|
||||
DISPATCH_SOURCE_TYPE_DECL(interval);
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_SOURCE_TYPE_VFS
|
||||
* @discussion Apple-internal dispatch source that monitors for vfs events
|
||||
* defined by dispatch_vfs_flags_t.
|
||||
* The handle is a process identifier (pid_t).
|
||||
*/
|
||||
#define DISPATCH_SOURCE_TYPE_VFS (&_dispatch_source_type_vfs)
|
||||
API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE()
|
||||
DISPATCH_SOURCE_TYPE_DECL(vfs);
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_SOURCE_TYPE_VM
|
||||
* @discussion A dispatch source that monitors virtual memory
|
||||
* The mask is a mask of desired events from dispatch_source_vm_flags_t.
|
||||
* This type is deprecated, use DISPATCH_SOURCE_TYPE_MEMORYPRESSURE instead.
|
||||
*/
|
||||
#define DISPATCH_SOURCE_TYPE_VM (&_dispatch_source_type_vm)
|
||||
API_DEPRECATED_WITH_REPLACEMENT("DISPATCH_SOURCE_TYPE_MEMORYPRESSURE",
|
||||
macos(10.7,10.10), ios(4.3,8.0)) DISPATCH_LINUX_UNAVAILABLE()
|
||||
DISPATCH_SOURCE_TYPE_DECL(vm);
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_SOURCE_TYPE_MEMORYSTATUS
|
||||
* @discussion A dispatch source that monitors memory status
|
||||
* The mask is a mask of desired events from
|
||||
* dispatch_source_memorystatus_flags_t.
|
||||
*/
|
||||
#define DISPATCH_SOURCE_TYPE_MEMORYSTATUS (&_dispatch_source_type_memorystatus)
|
||||
API_DEPRECATED_WITH_REPLACEMENT("DISPATCH_SOURCE_TYPE_MEMORYPRESSURE",
|
||||
macos(10.9, 10.12), ios(6.0, 10.0), tvos(6.0, 10.0), watchos(1.0, 3.0))
|
||||
DISPATCH_LINUX_UNAVAILABLE()
|
||||
DISPATCH_SOURCE_TYPE_DECL(memorystatus);
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_SOURCE_TYPE_SOCK
|
||||
* @discussion A dispatch source that monitors events on socket state changes.
|
||||
*/
|
||||
#define DISPATCH_SOURCE_TYPE_SOCK (&_dispatch_source_type_sock)
|
||||
API_AVAILABLE(macos(10.8), ios(6.0)) DISPATCH_LINUX_UNAVAILABLE()
|
||||
DISPATCH_SOURCE_TYPE_DECL(sock);
|
||||
|
||||
/*!
|
||||
* @const DISPATCH_SOURCE_TYPE_NW_CHANNEL
|
||||
* @discussion A dispatch source that monitors events on a network channel.
|
||||
*/
|
||||
#define DISPATCH_SOURCE_TYPE_NW_CHANNEL (&_dispatch_source_type_nw_channel)
|
||||
API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0)) DISPATCH_LINUX_UNAVAILABLE()
|
||||
DISPATCH_SOURCE_TYPE_DECL(nw_channel);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
/*!
|
||||
* @enum dispatch_source_sock_flags_t
|
||||
*
|
||||
* @constant DISPATCH_SOCK_CONNRESET
|
||||
* Received RST
|
||||
*
|
||||
* @constant DISPATCH_SOCK_READCLOSED
|
||||
* Read side is shutdown
|
||||
*
|
||||
* @constant DISPATCH_SOCK_WRITECLOSED
|
||||
* Write side is shutdown
|
||||
*
|
||||
* @constant DISPATCH_SOCK_TIMEOUT
|
||||
* Timeout: rexmt, keep-alive or persist
|
||||
*
|
||||
* @constant DISPATCH_SOCK_NOSRCADDR
|
||||
* Source address not available
|
||||
*
|
||||
* @constant DISPATCH_SOCK_IFDENIED
|
||||
* Interface denied connection
|
||||
*
|
||||
* @constant DISPATCH_SOCK_SUSPEND
|
||||
* Output queue suspended
|
||||
*
|
||||
* @constant DISPATCH_SOCK_RESUME
|
||||
* Output queue resumed
|
||||
*
|
||||
* @constant DISPATCH_SOCK_KEEPALIVE
|
||||
* TCP Keepalive received
|
||||
*
|
||||
* @constant DISPATCH_SOCK_CONNECTED
|
||||
* Socket is connected
|
||||
*
|
||||
* @constant DISPATCH_SOCK_DISCONNECTED
|
||||
* Socket is disconnected
|
||||
*
|
||||
* @constant DISPATCH_SOCK_CONNINFO_UPDATED
|
||||
* Connection info was updated
|
||||
*
|
||||
* @constant DISPATCH_SOCK_NOTIFY_ACK
|
||||
* Notify acknowledgement
|
||||
*/
|
||||
enum {
|
||||
DISPATCH_SOCK_CONNRESET = 0x00000001,
|
||||
DISPATCH_SOCK_READCLOSED = 0x00000002,
|
||||
DISPATCH_SOCK_WRITECLOSED = 0x00000004,
|
||||
DISPATCH_SOCK_TIMEOUT = 0x00000008,
|
||||
DISPATCH_SOCK_NOSRCADDR = 0x00000010,
|
||||
DISPATCH_SOCK_IFDENIED = 0x00000020,
|
||||
DISPATCH_SOCK_SUSPEND = 0x00000040,
|
||||
DISPATCH_SOCK_RESUME = 0x00000080,
|
||||
DISPATCH_SOCK_KEEPALIVE = 0x00000100,
|
||||
DISPATCH_SOCK_ADAPTIVE_WTIMO = 0x00000200,
|
||||
DISPATCH_SOCK_ADAPTIVE_RTIMO = 0x00000400,
|
||||
DISPATCH_SOCK_CONNECTED = 0x00000800,
|
||||
DISPATCH_SOCK_DISCONNECTED = 0x00001000,
|
||||
DISPATCH_SOCK_CONNINFO_UPDATED = 0x00002000,
|
||||
DISPATCH_SOCK_NOTIFY_ACK = 0x00004000,
|
||||
};
|
||||
|
||||
/*!
|
||||
* @enum dispatch_source_nw_channel_flags_t
|
||||
*
|
||||
* @constant DISPATCH_NW_CHANNEL_FLOW_ADV_UPDATE
|
||||
* Received network channel flow advisory.
|
||||
*/
|
||||
enum {
|
||||
DISPATCH_NW_CHANNEL_FLOW_ADV_UPDATE = 0x00000001,
|
||||
};
|
||||
|
||||
/*!
|
||||
* @enum dispatch_source_vfs_flags_t
|
||||
*
|
||||
* @constant DISPATCH_VFS_NOTRESP
|
||||
* Server down.
|
||||
*
|
||||
* @constant DISPATCH_VFS_NEEDAUTH
|
||||
* Server bad auth.
|
||||
*
|
||||
* @constant DISPATCH_VFS_LOWDISK
|
||||
* We're low on space.
|
||||
*
|
||||
* @constant DISPATCH_VFS_MOUNT
|
||||
* New filesystem arrived.
|
||||
*
|
||||
* @constant DISPATCH_VFS_UNMOUNT
|
||||
* Filesystem has left.
|
||||
*
|
||||
* @constant DISPATCH_VFS_DEAD
|
||||
* Filesystem is dead, needs force unmount.
|
||||
*
|
||||
* @constant DISPATCH_VFS_ASSIST
|
||||
* Filesystem needs assistance from external program.
|
||||
*
|
||||
* @constant DISPATCH_VFS_NOTRESPLOCK
|
||||
* Server lockd down.
|
||||
*
|
||||
* @constant DISPATCH_VFS_UPDATE
|
||||
* Filesystem information has changed.
|
||||
*
|
||||
* @constant DISPATCH_VFS_VERYLOWDISK
|
||||
* File system has *very* little disk space left.
|
||||
*
|
||||
* @constant DISPATCH_VFS_QUOTA
|
||||
* We hit a user quota (quotactl) for this filesystem.
|
||||
*
|
||||
* @constant DISPATCH_VFS_NEARLOWDISK
|
||||
* Filesystem is nearly full (below NEARLOWDISK level).
|
||||
*
|
||||
* @constant DISPATCH_VFS_DESIREDDISK
|
||||
* Filesystem has exceeded the DESIREDDISK level
|
||||
*
|
||||
* @constant DISPATCH_VFS_FREE_SPACE_CHANGE
|
||||
* Filesystem free space changed.
|
||||
*/
|
||||
enum {
|
||||
DISPATCH_VFS_NOTRESP = 0x0001,
|
||||
DISPATCH_VFS_NEEDAUTH = 0x0002,
|
||||
DISPATCH_VFS_LOWDISK = 0x0004,
|
||||
DISPATCH_VFS_MOUNT = 0x0008,
|
||||
DISPATCH_VFS_UNMOUNT = 0x0010,
|
||||
DISPATCH_VFS_DEAD = 0x0020,
|
||||
DISPATCH_VFS_ASSIST = 0x0040,
|
||||
DISPATCH_VFS_NOTRESPLOCK = 0x0080,
|
||||
DISPATCH_VFS_UPDATE = 0x0100,
|
||||
DISPATCH_VFS_VERYLOWDISK = 0x0200,
|
||||
DISPATCH_VFS_QUOTA = 0x1000,
|
||||
DISPATCH_VFS_NEARLOWDISK = 0x2000,
|
||||
DISPATCH_VFS_DESIREDDISK = 0x4000,
|
||||
DISPATCH_VFS_FREE_SPACE_CHANGE = 0x8000,
|
||||
};
|
||||
|
||||
/*!
|
||||
* @enum dispatch_clockid_t
|
||||
*
|
||||
* @discussion
|
||||
* These values can be used with DISPATCH_SOURCE_TYPE_TIMER as a "handle"
|
||||
* to anchor the timer to a given clock which allows for various optimizations.
|
||||
*
|
||||
* Note that using an explicit clock will make the dispatch source "strict"
|
||||
* like dispatch_source_set_mandatory_cancel_handler() does.
|
||||
*
|
||||
* @constant DISPATCH_CLOCKID_UPTIME
|
||||
* A monotonic clock that doesn't tick while the machine is asleep.
|
||||
* Equivalent to the CLOCK_UPTIME clock ID on BSD systems.
|
||||
*
|
||||
* @constant DISPATCH_CLOCKID_MONOTONIC
|
||||
* A monotonic clock that ticks while the machine sleeps.
|
||||
* Equivalent to POSIX CLOCK_MONOTONIC.
|
||||
* (Note that on Linux, CLOCK_MONOTONIC isn't conformant and doesn't tick while
|
||||
* sleeping, hence on Linux this is the same clock as CLOCK_BOOTTIME).
|
||||
*
|
||||
* @constant DISPATCH_CLOCKID_WALLTIME
|
||||
* A clock equivalent to the wall clock time, as returned by gettimeofday().
|
||||
* Equivalent to POSIX CLOCK_REALTIME.
|
||||
*
|
||||
* @constant DISPATCH_CLOCKID_REALTIME
|
||||
* An alias for DISPATCH_CLOCKID_WALLTIME to match the POSIX clock of the
|
||||
* same name.
|
||||
*/
|
||||
DISPATCH_ENUM(dispatch_clockid, uintptr_t,
|
||||
DISPATCH_CLOCKID_UPTIME DISPATCH_ENUM_API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) = 1,
|
||||
DISPATCH_CLOCKID_MONOTONIC DISPATCH_ENUM_API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) = 2,
|
||||
DISPATCH_CLOCKID_WALLTIME DISPATCH_ENUM_API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) = 3,
|
||||
DISPATCH_CLOCKID_REALTIME DISPATCH_ENUM_API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) = 3,
|
||||
);
|
||||
|
||||
/*!
|
||||
* @enum dispatch_source_timer_flags_t
|
||||
*
|
||||
* @constant DISPATCH_TIMER_BACKGROUND
|
||||
* Specifies that the timer is used to trigger low priority maintenance-level
|
||||
* activity and that the system may apply larger minimum leeway values to the
|
||||
* timer in order to align it with other system activity.
|
||||
*
|
||||
* @constant DISPATCH_INTERVAL_UI_ANIMATION
|
||||
* Specifies that the interval source is used for UI animation. The unit for
|
||||
* the interval value of such sources is frames (1/60th of a second) and the
|
||||
* leeway is fixed at one frame.
|
||||
*/
|
||||
enum {
|
||||
DISPATCH_TIMER_BACKGROUND = 0x2,
|
||||
DISPATCH_INTERVAL_UI_ANIMATION = 0x20,
|
||||
};
|
||||
|
||||
/*!
|
||||
* @enum dispatch_source_mach_send_flags_t
|
||||
*
|
||||
* @constant DISPATCH_MACH_SEND_POSSIBLE
|
||||
* The mach port corresponding to the given send right has space available
|
||||
* for messages. Delivered only once a mach_msg() to that send right with
|
||||
* options MACH_SEND_MSG|MACH_SEND_TIMEOUT|MACH_SEND_NOTIFY has returned
|
||||
* MACH_SEND_TIMED_OUT (and not again until the next such mach_msg() timeout).
|
||||
* NOTE: The source must have registered the send right for monitoring with the
|
||||
* system for such a mach_msg() to arm the send-possible notifcation, so
|
||||
* the initial send attempt must occur from a source registration handler.
|
||||
*/
|
||||
enum {
|
||||
DISPATCH_MACH_SEND_POSSIBLE = 0x8,
|
||||
};
|
||||
|
||||
/*!
|
||||
* @enum dispatch_source_proc_flags_t
|
||||
*
|
||||
* @constant DISPATCH_PROC_REAP
|
||||
* The process has been reaped by the parent process via wait*().
|
||||
* This flag is deprecated and will be removed in a future release.
|
||||
*
|
||||
* @constant DISPATCH_PROC_EXIT_STATUS
|
||||
* The process has exited. Specifying this flag allows the process exit status
|
||||
* to be retrieved from the source's status value, as returned by the
|
||||
* dispatch_source_get_extended_data() function. The macros
|
||||
* DISPATCH_PROC_EXIT_STATUS_EXITED(), DISPATCH_PROC_EXIT_STATUS_CODE(),
|
||||
* DISPATCH_PROC_EXIT_STATUS_SIGNALED(), DISPATCH_PROC_EXIT_STATUS_TERMSIG() and
|
||||
* DISPATCH_PROC_EXIT_STATUS_CORE_DUMPED() can be used to examine the status
|
||||
* value.
|
||||
*/
|
||||
enum {
|
||||
DISPATCH_PROC_REAP DISPATCH_ENUM_API_DEPRECATED("unsupported flag",
|
||||
macos(10.6,10.9), ios(4.0,7.0)) = 0x10000000,
|
||||
DISPATCH_PROC_EXIT_STATUS DISPATCH_ENUM_API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(2.0)) = 0x04000000,
|
||||
};
|
||||
|
||||
/*!
|
||||
* @enum dispatch_source_vm_flags_t
|
||||
*
|
||||
* @constant DISPATCH_VM_PRESSURE
|
||||
* The VM has experienced memory pressure.
|
||||
*/
|
||||
|
||||
enum {
|
||||
DISPATCH_VM_PRESSURE DISPATCH_ENUM_API_DEPRECATED_WITH_REPLACEMENT("DISPATCH_MEMORYPRESSURE_WARN", macos(10.7, 10.10), ios(4.3, 8.0))
|
||||
= 0x80000000,
|
||||
};
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_source_memorypressure_flags_t
|
||||
* Type of dispatch_source_memorypressure flags
|
||||
*
|
||||
* @constant DISPATCH_MEMORYPRESSURE_LOW_SWAP
|
||||
* The system's memory pressure state has entered the "low swap" condition.
|
||||
* Restricted to the root user.
|
||||
*/
|
||||
enum {
|
||||
DISPATCH_MEMORYPRESSURE_LOW_SWAP DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x08,
|
||||
};
|
||||
|
||||
/*!
|
||||
* @enum dispatch_source_memorystatus_flags_t
|
||||
* @warning Deprecated, see DISPATCH_MEMORYPRESSURE_*
|
||||
*/
|
||||
enum {
|
||||
DISPATCH_MEMORYSTATUS_PRESSURE_NORMAL
|
||||
DISPATCH_ENUM_API_DEPRECATED_WITH_REPLACEMENT("DISPATCH_MEMORYPRESSURE_NORMAL", macos(10.9, 10.12),
|
||||
ios(6.0, 10.0), tvos(6.0, 10.0), watchos(1.0, 3.0)) = 0x01,
|
||||
DISPATCH_MEMORYSTATUS_PRESSURE_WARN
|
||||
DISPATCH_ENUM_API_DEPRECATED_WITH_REPLACEMENT("DISPATCH_MEMORYPRESSURE_WARN", macos(10.9, 10.12),
|
||||
ios(6.0, 10.0), tvos(6.0, 10.0), watchos(1.0, 3.0)) = 0x02,
|
||||
DISPATCH_MEMORYSTATUS_PRESSURE_CRITICAL
|
||||
DISPATCH_ENUM_API_DEPRECATED_WITH_REPLACEMENT("DISPATCH_MEMORYPRESSURE_CRITICAL", macos(10.9, 10.12),
|
||||
ios(6.0, 10.0), tvos(6.0, 10.0), watchos(1.0, 3.0)) = 0x04,
|
||||
DISPATCH_MEMORYSTATUS_LOW_SWAP
|
||||
DISPATCH_ENUM_API_DEPRECATED_WITH_REPLACEMENT("DISPATCH_MEMORYPRESSURE_LOW_SWAP", macos(10.9, 10.12),
|
||||
ios(6.0, 10.0), tvos(6.0, 10.0), watchos(1.0, 3.0)) = 0x08,
|
||||
};
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_source_memorypressure_flags_t
|
||||
* Type of dispatch_source_memorypressure flags
|
||||
*
|
||||
* @constant DISPATCH_MEMORYPRESSURE_PROC_LIMIT_WARN
|
||||
* The memory of the process has crossed 80% of its high watermark limit.
|
||||
*
|
||||
* @constant DISPATCH_MEMORYPRESSURE_PROC_LIMIT_CRITICAL
|
||||
* The memory of the process has reached 100% of its high watermark limit.
|
||||
*
|
||||
* @constant DISPATCH_MEMORYPRESSURE_MSL_STATUS
|
||||
* Mask for enabling/disabling malloc stack logging.
|
||||
*/
|
||||
enum {
|
||||
DISPATCH_MEMORYPRESSURE_PROC_LIMIT_WARN DISPATCH_ENUM_API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) = 0x10,
|
||||
|
||||
DISPATCH_MEMORYPRESSURE_PROC_LIMIT_CRITICAL DISPATCH_ENUM_API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) = 0x20,
|
||||
|
||||
DISPATCH_MEMORYPRESSURE_MSL_STATUS DISPATCH_ENUM_API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0)) = 0xf0000000,
|
||||
};
|
||||
|
||||
/*!
|
||||
* Macros to check the exit status obtained from the status field of the
|
||||
* structure returned by the dispatch_source_get_extended_data() function for a
|
||||
* source of type DISPATCH_SOURCE_TYPE_PROC when DISPATCH_PROC_EXIT_STATUS has
|
||||
* been requested.
|
||||
*
|
||||
* DISPATCH_PROC_EXIT_STATUS_EXITED returns whether the process exited. If this
|
||||
* is true, the exit status can be obtained from DISPATCH_PROC_EXIT_STATUS_CODE.
|
||||
*
|
||||
* DISPATCH_PROC_EXIT_STATUS_SIGNALED returns whether the process was terminated
|
||||
* by a signal.
|
||||
*
|
||||
* DISPATCH_PROC_EXIT_STATUS_TERMSIG returns the signal that caused the process
|
||||
* to terminate, or 0 if the process was not terminated by a signal.
|
||||
*
|
||||
* DISPATCH_PROC_EXIT_STATUS_CORE_DUMPED returns whether a core dump of the
|
||||
* process was created.
|
||||
*/
|
||||
#define DISPATCH_PROC_EXIT_STATUS_EXITED(status) ((bool)WIFEXITED(status))
|
||||
#define DISPATCH_PROC_EXIT_STATUS_CODE(status) ((int)WEXITSTATUS(status))
|
||||
#define DISPATCH_PROC_EXIT_STATUS_SIGNALED(status) ((bool)WIFSIGNALED(status))
|
||||
#define DISPATCH_PROC_EXIT_STATUS_TERMSIG(status) ((int)WTERMSIG(status))
|
||||
#define DISPATCH_PROC_EXIT_STATUS_CORE_DUMPED(status) ((bool)WCOREDUMP(status))
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*!
|
||||
* @function dispatch_source_set_mandatory_cancel_handler
|
||||
*
|
||||
* @abstract
|
||||
* Sets the event handler block for the given dispatch source, and indicates
|
||||
* that calling dispatch_source_cancel() is mandatory for this source object.
|
||||
*
|
||||
* @discussion
|
||||
* The cancellation handler (if specified) will be submitted to the source's
|
||||
* target queue in response to a call to dispatch_source_cancel() once the
|
||||
* system has released all references to the source's underlying handle and
|
||||
* the source's event handler block has returned.
|
||||
*
|
||||
* When this function has been used used to set a cancellation handler, then
|
||||
* the following result in an assertion and the process being terminated:
|
||||
* - releasing the last reference on the dispatch source without having
|
||||
* cancelled it by calling dispatch_source_cancel();
|
||||
* - changing any handler after the source has been activated;
|
||||
* - changing the target queue of the source after it has been activated.
|
||||
*
|
||||
* IMPORTANT:
|
||||
* Source cancellation and a cancellation handler are required for file
|
||||
* descriptor and mach port based sources in order to safely close the
|
||||
* descriptor or destroy the port. Making the cancellation handler of such
|
||||
* sources mandatory is strongly recommended.
|
||||
* Closing the descriptor or port before the cancellation handler is invoked may
|
||||
* result in a race condition. If a new descriptor is allocated with the same
|
||||
* value as the recently closed descriptor while the source's event handler is
|
||||
* still running, the event handler may read/write data to the wrong descriptor.
|
||||
*
|
||||
* @param source
|
||||
* The dispatch source to modify.
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*
|
||||
* @param handler
|
||||
* The cancellation handler block to submit to the source's target queue.
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*/
|
||||
#ifdef __BLOCKS__
|
||||
API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_source_set_mandatory_cancel_handler(dispatch_source_t source,
|
||||
dispatch_block_t handler);
|
||||
#endif /* __BLOCKS__ */
|
||||
|
||||
/*!
|
||||
* @function dispatch_source_set_mandatory_cancel_handler_f
|
||||
*
|
||||
* @abstract
|
||||
* Sets the event handler function for the given dispatch source, and causes an
|
||||
* assertion if this source is released before having been explicitly canceled.
|
||||
*
|
||||
* @discussion
|
||||
* See dispatch_source_set_mandatory_cancel_handler() for more details.
|
||||
*
|
||||
* @param source
|
||||
* The dispatch source to modify.
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*
|
||||
* @param handler
|
||||
* The cancellation handler function to submit to the source's target queue.
|
||||
* The context parameter passed to the event handler function is the current
|
||||
* context of the dispatch source at the time the handler call is made.
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_source_set_mandatory_cancel_handler_f(dispatch_source_t source,
|
||||
dispatch_function_t handler);
|
||||
|
||||
/*!
|
||||
* @function dispatch_source_cancel_and_wait
|
||||
*
|
||||
* @abstract
|
||||
* Synchronously cancel the dispatch source, preventing any further invocation
|
||||
* of its event handler block.
|
||||
*
|
||||
* @discussion
|
||||
* Cancellation prevents any further invocation of handler blocks for the
|
||||
* specified dispatch source, but does not interrupt a handler block that is
|
||||
* already in progress.
|
||||
*
|
||||
* When this function returns, any handler block that may have been in progress
|
||||
* has returned, the specified source has been unregistered and it is safe to
|
||||
* reclaim any system resource (such as file descriptors or mach ports) that
|
||||
* the specified source was monitoring.
|
||||
*
|
||||
* If the specified dispatch source is inactive, it will be activated as a side
|
||||
* effect of calling this function.
|
||||
*
|
||||
* It is possible to call this function from several threads concurrently,
|
||||
* and it is the responsibility of the callers to synchronize reclaiming the
|
||||
* associated system resources.
|
||||
*
|
||||
* This function is not subject to priority inversion when it is waiting on
|
||||
* a handler block still in progress, unlike patterns based on waiting on
|
||||
* a dispatch semaphore or a dispatch group signaled (or left) from the source
|
||||
* cancel handler.
|
||||
*
|
||||
* This function must not be called if the specified source has a cancel
|
||||
* handler set, or from the context of its handler blocks.
|
||||
*
|
||||
* This function must not be called from the context of the target queue of
|
||||
* the specified source or from any queue that synchronizes with it. Note that
|
||||
* calling dispatch_source_cancel() from such a context already guarantees
|
||||
* that no handler is in progress, and that no new event will be delivered.
|
||||
*
|
||||
* This function must not be called on sources suspended with an explicit
|
||||
* call to dispatch_suspend(), or being concurrently activated on another
|
||||
* thread.
|
||||
*
|
||||
* @param source
|
||||
* The dispatch source to be canceled.
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
|
||||
DISPATCH_EXPORT DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_source_cancel_and_wait(dispatch_source_t source);
|
||||
|
||||
#if __has_include(<mach/mach.h>)
|
||||
/*!
|
||||
* @typedef dispatch_mig_callback_t
|
||||
*
|
||||
* @abstract
|
||||
* The signature of a function that handles Mach message delivery and response.
|
||||
*/
|
||||
typedef boolean_t (*dispatch_mig_callback_t)(mach_msg_header_t *message,
|
||||
mach_msg_header_t *reply);
|
||||
|
||||
API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE()
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
mach_msg_return_t
|
||||
dispatch_mig_server(dispatch_source_t ds, size_t maxmsgsz,
|
||||
dispatch_mig_callback_t callback);
|
||||
|
||||
/*!
|
||||
* @function dispatch_mach_msg_get_context
|
||||
*
|
||||
* @abstract
|
||||
* Extract the context pointer from a mach message trailer.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE()
|
||||
DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NONNULL_ALL
|
||||
DISPATCH_NOTHROW
|
||||
void *_Nullable
|
||||
dispatch_mach_msg_get_context(mach_msg_header_t *msg);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_source_extended_data_t
|
||||
*
|
||||
* @abstract
|
||||
* Type used by dispatch_source_get_extended_data() to return a consistent
|
||||
* snapshot of the data and status of a dispatch source.
|
||||
*/
|
||||
typedef struct dispatch_source_extended_data_s {
|
||||
unsigned long data;
|
||||
unsigned long status;
|
||||
} *dispatch_source_extended_data_t;
|
||||
|
||||
/*!
|
||||
* @function dispatch_source_get_extended_data
|
||||
*
|
||||
* @abstract
|
||||
* Returns the current data and status values for a dispatch source.
|
||||
*
|
||||
* @discussion
|
||||
* This function is intended to be called from within the event handler block.
|
||||
* The result of calling this function outside of the event handler callback is
|
||||
* undefined.
|
||||
*
|
||||
* @param source
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*
|
||||
* @param data
|
||||
* A pointer to a dispatch_source_extended_data_s in which the data and status
|
||||
* will be returned. The data field is populated with the value that would be
|
||||
* returned by dispatch_source_get_data(). The value of the status field should
|
||||
* be interpreted according to the type of the dispatch source:
|
||||
*
|
||||
* DISPATCH_SOURCE_TYPE_PROC: dispatch_source_proc_exit_flags_t
|
||||
*
|
||||
* If called from the event handler of a data source type not listed above, the
|
||||
* status value is undefined.
|
||||
*
|
||||
* @param size
|
||||
* The size of the specified structure. Should be set to
|
||||
* sizeof(dispatch_source_extended_data_s).
|
||||
*
|
||||
* @result
|
||||
* The size of the structure returned in *data, which will never be greater than
|
||||
* the value of the size argument. If this is less than the value of the size
|
||||
* argument, the remaining space in data will have been populated with zeroes.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
|
||||
DISPATCH_NOTHROW
|
||||
size_t
|
||||
dispatch_source_get_extended_data(dispatch_source_t source,
|
||||
dispatch_source_extended_data_t data, size_t size);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
87
Telegram/ThirdParty/dispatch/private/time_private.h
vendored
Normal file
87
Telegram/ThirdParty/dispatch/private/time_private.h
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 20017 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
* IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
|
||||
* which are subject to change in future releases. Any applications relying on
|
||||
* these interfaces WILL break.
|
||||
*/
|
||||
|
||||
#ifndef __DISPATCH_TIME_PRIVATE__
|
||||
#define __DISPATCH_TIME_PRIVATE__
|
||||
|
||||
#ifndef __DISPATCH_INDIRECT__
|
||||
#error "Please #include <dispatch/private.h> instead of this file directly."
|
||||
#include <dispatch/base.h> // for HeaderDoc
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @constant DISPATCH_MONOTONICTIME_NOW
|
||||
* A dispatch_time_t value that corresponds to the current value of the
|
||||
* platform's monotonic clock. On Apple platforms, this clock is based on
|
||||
* mach_continuous_time(). Use this value with the dispatch_time() function to
|
||||
* derive a time value for a timer in monotonic time (i.e. a timer that
|
||||
* continues to tick while the system is asleep). For example:
|
||||
*
|
||||
* dispatch_time_t t = dispatch_time(DISPATCH_MONOTONICTIME_NOW,5*NSEC_PER_SEC);
|
||||
* dispatch_source_t ds = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER,
|
||||
* 0, 0, q);
|
||||
* dispatch_source_set_event_handler(ds, ^{ ... });
|
||||
* dispatch_source_set_timer(ds, t, 10 * NSEC_PER_SEC, 0);
|
||||
* dispatch_activate(ds);
|
||||
*/
|
||||
enum {
|
||||
DISPATCH_MONOTONICTIME_NOW DISPATCH_ENUM_API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) = (1ull << 63)
|
||||
};
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
// Helper macros for up time, montonic time and wall time.
|
||||
#define _dispatch_uptime_after_nsec(t) \
|
||||
dispatch_time(DISPATCH_TIME_NOW, (t))
|
||||
#define _dispatch_uptime_after_usec(t) \
|
||||
dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_USEC)
|
||||
#define _dispatch_uptime_after_msec(t) \
|
||||
dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_MSEC)
|
||||
#define _dispatch_uptime_after_sec(t) \
|
||||
dispatch_time(DISPATCH_TIME_NOW, (t) * NSEC_PER_SEC)
|
||||
|
||||
#define _dispatch_monotonictime_after_nsec(t) \
|
||||
dispatch_time(DISPATCH_MONOTONICTIME_NOW, (t))
|
||||
#define _dispatch_monotonictime_after_usec(t) \
|
||||
dispatch_time(DISPATCH_MONOTONICTIME_NOW, (t) * NSEC_PER_USEC)
|
||||
#define _dispatch_monotonictime_after_msec(t) \
|
||||
dispatch_time(DISPATCH_MONOTONICTIME_NOW, (t) * NSEC_PER_MSEC)
|
||||
#define _dispatch_monotonictime_after_sec(t) \
|
||||
dispatch_time(DISPATCH_MONOTONICTIME_NOW, (t) * NSEC_PER_SEC)
|
||||
|
||||
#define _dispatch_walltime_after_nsec(t) \
|
||||
dispatch_time(DISPATCH_WALLTIME_NOW, (t))
|
||||
#define _dispatch_walltime_after_usec(t) \
|
||||
dispatch_time(DISPATCH_WALLTIME_NOW, (t) * NSEC_PER_USEC)
|
||||
#define _dispatch_walltime_after_msec(t) \
|
||||
dispatch_time(DISPATCH_WALLTIME_NOW, (t) * NSEC_PER_MSEC)
|
||||
#define _dispatch_walltime_after_sec(t) \
|
||||
dispatch_time(DISPATCH_WALLTIME_NOW, (t) * NSEC_PER_SEC)
|
||||
|
||||
#endif // __APPLE__
|
||||
|
||||
#endif
|
||||
|
||||
440
Telegram/ThirdParty/dispatch/private/workloop_private.h
vendored
Normal file
440
Telegram/ThirdParty/dispatch/private/workloop_private.h
vendored
Normal file
@@ -0,0 +1,440 @@
|
||||
/*
|
||||
* Copyright (c) 2017-2018 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
/*
|
||||
* IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
|
||||
* which are subject to change in future releases of Mac OS X. Any applications
|
||||
* relying on these interfaces WILL break.
|
||||
*/
|
||||
|
||||
#ifndef __DISPATCH_WORKLOOP_PRIVATE__
|
||||
#define __DISPATCH_WORKLOOP_PRIVATE__
|
||||
|
||||
#ifndef __DISPATCH_INDIRECT__
|
||||
#error "Please #include <dispatch/private.h> instead of this file directly."
|
||||
#include <dispatch/base.h> // for HeaderDoc
|
||||
#endif
|
||||
|
||||
/******************************************************************************\
|
||||
*
|
||||
* THIS FILE IS AN IN-PROGRESS INTERFACE THAT IS SUBJECT TO CHANGE
|
||||
*
|
||||
\******************************************************************************/
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_BEGIN
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*!
|
||||
* @typedef dispatch_workloop_t
|
||||
*
|
||||
* @abstract
|
||||
* Dispatch workloops invoke workitems submitted to them in priority order.
|
||||
*
|
||||
* @discussion
|
||||
* A dispatch workloop is a flavor of dispatch_queue_t that is a priority
|
||||
* ordered queue (using the QOS class of the submitted workitems as the
|
||||
* ordering).
|
||||
*
|
||||
* Between each workitem invocation, the workloop will evaluate whether higher
|
||||
* priority workitems have since been submitted and execute these first.
|
||||
*
|
||||
* Serial queues targeting a workloop maintain FIFO execution of their
|
||||
* workitems. However, the workloop may reorder workitems submitted to
|
||||
* independent serial queues targeting it with respect to each other,
|
||||
* based on their priorities.
|
||||
*
|
||||
* A dispatch workloop is a "subclass" of dispatch_queue_t which can be passed
|
||||
* to all APIs accepting a dispatch queue, except for functions from the
|
||||
* dispatch_sync() family. dispatch_async_and_wait() must be used for workloop
|
||||
* objects. Functions from the dispatch_sync() family on queues targeting
|
||||
* a workloop are still permitted but discouraged for performance reasons.
|
||||
*/
|
||||
#if defined(__DISPATCH_BUILDING_DISPATCH__) && !defined(__OBJC__)
|
||||
typedef struct dispatch_workloop_s *dispatch_workloop_t;
|
||||
#else
|
||||
DISPATCH_DECL_SUBCLASS(dispatch_workloop, dispatch_queue);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @function dispatch_workloop_create
|
||||
*
|
||||
* @abstract
|
||||
* Creates a new dispatch workloop to which workitems may be submitted.
|
||||
*
|
||||
* @param label
|
||||
* A string label to attach to the workloop.
|
||||
*
|
||||
* @result
|
||||
* The newly created dispatch workloop.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
|
||||
DISPATCH_NOTHROW
|
||||
dispatch_workloop_t
|
||||
dispatch_workloop_create(const char *_Nullable label);
|
||||
|
||||
/*!
|
||||
* @function dispatch_workloop_create_inactive
|
||||
*
|
||||
* @abstract
|
||||
* Creates a new inactive dispatch workloop that can be setup and then
|
||||
* activated.
|
||||
*
|
||||
* @discussion
|
||||
* Creating an inactive workloop allows for it to receive further configuration
|
||||
* before it is activated, and workitems can be submitted to it.
|
||||
*
|
||||
* Submitting workitems to an inactive workloop is undefined and will cause the
|
||||
* process to be terminated.
|
||||
*
|
||||
* @param label
|
||||
* A string label to attach to the workloop.
|
||||
*
|
||||
* @result
|
||||
* The newly created dispatch workloop.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
|
||||
DISPATCH_NOTHROW
|
||||
dispatch_workloop_t
|
||||
dispatch_workloop_create_inactive(const char *_Nullable label);
|
||||
|
||||
/*!
|
||||
* @function dispatch_workloop_set_autorelease_frequency
|
||||
*
|
||||
* @abstract
|
||||
* Sets the autorelease frequency of the workloop.
|
||||
*
|
||||
* @discussion
|
||||
* See dispatch_queue_attr_make_with_autorelease_frequency().
|
||||
* The default policy for a workloop is
|
||||
* DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM.
|
||||
*
|
||||
* @param workloop
|
||||
* The dispatch workloop to modify.
|
||||
*
|
||||
* This workloop must be inactive, passing an activated object is undefined
|
||||
* and will cause the process to be terminated.
|
||||
*
|
||||
* @param frequency
|
||||
* The requested autorelease frequency.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_workloop_set_autorelease_frequency(dispatch_workloop_t workloop,
|
||||
dispatch_autorelease_frequency_t frequency);
|
||||
|
||||
DISPATCH_ENUM(dispatch_workloop_param_flags, uint64_t,
|
||||
DISPATCH_WORKLOOP_NONE DISPATCH_ENUM_API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) = 0x0,
|
||||
DISPATCH_WORKLOOP_FIXED_PRIORITY DISPATCH_ENUM_API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) = 0x1,
|
||||
);
|
||||
|
||||
/*!
|
||||
* @function dispatch_workloop_set_qos_class_floor
|
||||
*
|
||||
* @abstract
|
||||
* Sets the QOS class floor of a workloop.
|
||||
*
|
||||
* @discussion
|
||||
* See dispatch_set_qos_class_floor().
|
||||
*
|
||||
* This function is strictly equivalent to dispatch_set_qos_class_floor() but
|
||||
* allows to pass extra flags.
|
||||
*
|
||||
* Using both dispatch_workloop_set_scheduler_priority() and
|
||||
* dispatch_set_qos_class_floor() or dispatch_workloop_set_qos_class_floor()
|
||||
* is undefined and will cause the process to be terminated.
|
||||
*
|
||||
* @param workloop
|
||||
* The dispatch workloop to modify.
|
||||
*
|
||||
* This workloop must be inactive, passing an activated object is undefined
|
||||
* and will cause the process to be terminated.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_workloop_set_qos_class_floor(dispatch_workloop_t workloop,
|
||||
dispatch_qos_class_t qos, int relpri, dispatch_workloop_param_flags_t flags);
|
||||
|
||||
/*!
|
||||
* @function dispatch_workloop_set_scheduler_priority
|
||||
*
|
||||
* @abstract
|
||||
* Sets the scheduler priority for a dispatch workloop.
|
||||
*
|
||||
* @discussion
|
||||
* This sets the scheduler priority of the threads that the runtime will bring
|
||||
* up to service this workloop.
|
||||
*
|
||||
* QOS propagation still functions on these workloops, but its effect on the
|
||||
* priority of the thread brought up to service this workloop is ignored.
|
||||
*
|
||||
* Using both dispatch_workloop_set_scheduler_priority() and
|
||||
* dispatch_set_qos_class_floor() or dispatch_workloop_set_qos_class_floor()
|
||||
* is undefined and will cause the process to be terminated.
|
||||
*
|
||||
* @param workloop
|
||||
* The dispatch workloop to modify.
|
||||
*
|
||||
* This workloop must be inactive, passing an activated object is undefined
|
||||
* and will cause the process to be terminated.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_workloop_set_scheduler_priority(dispatch_workloop_t workloop,
|
||||
int priority, dispatch_workloop_param_flags_t flags);
|
||||
|
||||
/*!
|
||||
* @function dispatch_workloop_set_cpupercent
|
||||
*
|
||||
* @abstract
|
||||
* Sets the cpu percent and refill attributes for a dispatch workloop.
|
||||
*
|
||||
* @discussion
|
||||
* This should only used if the workloop was also setup with the
|
||||
* DISPATCH_WORKLOOP_FIXED_PRIORITY flag as a safe guard against
|
||||
* busy loops that could starve the rest of the system forever.
|
||||
*
|
||||
* If DISPATCH_WORKLOOP_FIXED_PRIORITY wasn't passed, using this function is
|
||||
* undefined and will cause the process to be terminated.
|
||||
*
|
||||
* @param workloop
|
||||
* The dispatch workloop to modify.
|
||||
*
|
||||
* This workloop must be inactive, passing an activated object is undefined
|
||||
* and will cause the process to be terminated.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_workloop_set_cpupercent(dispatch_workloop_t workloop, uint8_t percent,
|
||||
uint32_t refillms);
|
||||
|
||||
/*!
|
||||
* @function dispatch_workloop_is_current()
|
||||
*
|
||||
* @abstract
|
||||
* Returns whether the current thread has been made by the runtime to service
|
||||
* this workloop.
|
||||
*
|
||||
* @discussion
|
||||
* Note that when using <code>dispatch_async_and_wait(workloop, ^{ ... })</code>
|
||||
* then <code>workloop</code> will be seen as the "current" one by the submitted
|
||||
* workitem, but that is not the case when using dispatch_sync() on a queue
|
||||
* targeting the workloop.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
bool
|
||||
dispatch_workloop_is_current(dispatch_workloop_t workloop);
|
||||
|
||||
/*!
|
||||
* @function dispatch_workloop_copy_current()
|
||||
*
|
||||
* @abstract
|
||||
* Returns a copy of the workoop that is being serviced on the calling thread
|
||||
* if any.
|
||||
*
|
||||
* @discussion
|
||||
* If the thread is not a workqueue thread, or is not servicing a dispatch
|
||||
* workloop, then NULL is returned.
|
||||
*
|
||||
* This returns a retained object that must be released with dispatch_release().
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_RETURNS_RETAINED DISPATCH_NOTHROW
|
||||
dispatch_workloop_t _Nullable
|
||||
dispatch_workloop_copy_current(void);
|
||||
|
||||
// Equivalent to dispatch_workloop_set_qos_class_floor(workoop, qos, 0, flags)
|
||||
API_DEPRECATED_WITH_REPLACEMENT("dispatch_workloop_set_qos_class_floor",
|
||||
macos(10.14,10.14), ios(12.0,12.0), tvos(12.0,12.0), watchos(5.0,5.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_workloop_set_qos_class(dispatch_workloop_t workloop,
|
||||
dispatch_qos_class_t qos, dispatch_workloop_param_flags_t flags);
|
||||
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_NOTHROW
|
||||
bool
|
||||
_dispatch_workloop_should_yield_4NW(void);
|
||||
|
||||
/*!
|
||||
* @function dispatch_async_and_wait
|
||||
*
|
||||
* @abstract
|
||||
* Submits a block for synchronous execution on a dispatch queue.
|
||||
*
|
||||
* @discussion
|
||||
* Submits a workitem to a dispatch queue like dispatch_async(), however
|
||||
* dispatch_async_and_wait() will not return until the workitem has finished.
|
||||
*
|
||||
* Like functions of the dispatch_sync family, dispatch_async_and_wait() is
|
||||
* subject to dead-lock (See dispatch_sync() for details).
|
||||
*
|
||||
* However, dispatch_async_and_wait() differs from functions of the
|
||||
* dispatch_sync family in two fundamental ways: how it respects queue
|
||||
* attributes and how it chooses the execution context invoking the workitem.
|
||||
*
|
||||
* <b>Differences with dispatch_sync()</b>
|
||||
*
|
||||
* Work items submitted to a queue with dispatch_async_and_wait() observe all
|
||||
* queue attributes of that queue when invoked (inluding autorelease frequency
|
||||
* or QOS class).
|
||||
*
|
||||
* When the runtime has brought up a thread to invoke the asynchronous workitems
|
||||
* already submitted to the specified queue, that servicing thread will also be
|
||||
* used to execute synchronous work submitted to the queue with
|
||||
* dispatch_async_and_wait().
|
||||
*
|
||||
* However, if the runtime has not brought up a thread to service the specified
|
||||
* queue (because it has no workitems enqueued, or only synchronous workitems),
|
||||
* then dispatch_async_and_wait() will invoke the workitem on the calling thread,
|
||||
* similar to the behaviour of functions in the dispatch_sync family.
|
||||
*
|
||||
* As an exception, if the queue the work is submitted to doesn't target
|
||||
* a global concurrent queue (for example because it targets the main queue),
|
||||
* then the workitem will never be invoked by the thread calling
|
||||
* dispatch_async_and_wait().
|
||||
*
|
||||
* In other words, dispatch_async_and_wait() is similar to submitting
|
||||
* a dispatch_block_create()d workitem to a queue and then waiting on it, as
|
||||
* shown in the code example below. However, dispatch_async_and_wait() is
|
||||
* significantly more efficient when a new thread is not required to execute
|
||||
* the workitem (as it will use the stack of the submitting thread instead of
|
||||
* requiring heap allocations).
|
||||
*
|
||||
* <code>
|
||||
* dispatch_block_t b = dispatch_block_create(0, block);
|
||||
* dispatch_async(queue, b);
|
||||
* dispatch_block_wait(b, DISPATCH_TIME_FOREVER);
|
||||
* Block_release(b);
|
||||
* </code>
|
||||
*
|
||||
* @param queue
|
||||
* The target dispatch queue to which the block is submitted.
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*
|
||||
* @param block
|
||||
* The block to be invoked on the target dispatch queue.
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*/
|
||||
#ifdef __BLOCKS__
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_async_and_wait(dispatch_queue_t queue,
|
||||
DISPATCH_NOESCAPE dispatch_block_t block);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @function dispatch_async_and_wait_f
|
||||
*
|
||||
* @abstract
|
||||
* Submits a function for synchronous execution on a dispatch queue.
|
||||
*
|
||||
* @discussion
|
||||
* See dispatch_async_and_wait() for details.
|
||||
*
|
||||
* @param queue
|
||||
* The target dispatch queue to which the function is submitted.
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*
|
||||
* @param context
|
||||
* The application-defined context parameter to pass to the function.
|
||||
*
|
||||
* @param work
|
||||
* The application-defined function to invoke on the target queue. The first
|
||||
* parameter passed to this function is the context provided to
|
||||
* dispatch_async_and_wait_f().
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_async_and_wait_f(dispatch_queue_t queue,
|
||||
void *_Nullable context, dispatch_function_t work);
|
||||
|
||||
/*!
|
||||
* @function dispatch_barrier_async_and_wait
|
||||
*
|
||||
* @abstract
|
||||
* Submits a block for synchronous execution on a dispatch queue.
|
||||
*
|
||||
* @discussion
|
||||
* Submits a block to a dispatch queue like dispatch_async_and_wait(), but marks
|
||||
* that block as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT
|
||||
* queues).
|
||||
*
|
||||
* @param queue
|
||||
* The target dispatch queue to which the block is submitted.
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*
|
||||
* @param work
|
||||
* The application-defined block to invoke on the target queue.
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*/
|
||||
#ifdef __BLOCKS__
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_barrier_async_and_wait(dispatch_queue_t queue,
|
||||
DISPATCH_NOESCAPE dispatch_block_t block);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @function dispatch_barrier_async_and_wait_f
|
||||
*
|
||||
* @abstract
|
||||
* Submits a function for synchronous execution on a dispatch queue.
|
||||
*
|
||||
* @discussion
|
||||
* Submits a function to a dispatch queue like dispatch_async_and_wait_f(), but
|
||||
* marks that function as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT
|
||||
* queues).
|
||||
*
|
||||
* @param queue
|
||||
* The target dispatch queue to which the function is submitted.
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*
|
||||
* @param context
|
||||
* The application-defined context parameter to pass to the function.
|
||||
*
|
||||
* @param work
|
||||
* The application-defined function to invoke on the target queue. The first
|
||||
* parameter passed to this function is the context provided to
|
||||
* dispatch_barrier_async_and_wait_f().
|
||||
* The result of passing NULL in this parameter is undefined.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
|
||||
void
|
||||
dispatch_barrier_async_and_wait_f(dispatch_queue_t queue,
|
||||
void *_Nullable context, dispatch_function_t work);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
DISPATCH_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user