1#![no_std]
20#![allow(unreachable_patterns)]
21#![warn(missing_docs)]
22#![warn(missing_debug_implementations)]
23#![warn(clippy::undocumented_unsafe_blocks)]
24#![warn(clippy::missing_safety_doc)]
25#![doc(html_root_url = "https://docs.rs/dispatch2/0.3.0")]
27
28#[cfg(not(feature = "alloc"))]
29compile_error!("The `alloc` feature currently must be enabled.");
30
31extern crate alloc;
32
33#[cfg(feature = "std")]
34extern crate std;
35
36#[macro_use]
37mod macros;
38
39use core::cell::UnsafeCell;
40use core::marker::{PhantomData, PhantomPinned};
41
42mod data;
43#[allow(clippy::undocumented_unsafe_blocks, unreachable_pub)]
44mod generated;
45mod group;
46mod io;
47#[cfg(feature = "objc2")]
48mod main_thread_bound;
49mod object;
50mod once;
51mod queue;
52mod retained;
53mod semaphore;
54mod source;
55mod time;
56mod utils;
57mod workloop;
58
59#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
61#[non_exhaustive]
62pub enum WaitError {
63 TimeOverflow,
65 Timeout,
67}
68
69pub use self::data::DispatchData;
70#[cfg(feature = "block2")]
71pub use self::generated::{
72 _dispatch_data_destructor_free, _dispatch_data_destructor_munmap, dispatch_block_cancel,
73 dispatch_block_create, dispatch_block_create_with_qos_class, dispatch_block_notify,
74 dispatch_block_perform, dispatch_block_t, dispatch_block_testcancel, dispatch_block_wait,
75 dispatch_data_applier_t, dispatch_io_handler_t, dispatch_read, dispatch_write,
76};
77pub use self::generated::{
78 dispatch_allow_send_signals, dispatch_fd_t, dispatch_get_specific, dispatch_once_t,
79 DispatchAutoReleaseFrequency, _dispatch_source_type_data_add, _dispatch_source_type_data_or,
80 _dispatch_source_type_data_replace, _dispatch_source_type_mach_recv,
81 _dispatch_source_type_mach_send, _dispatch_source_type_memorypressure,
82 _dispatch_source_type_proc, _dispatch_source_type_read, _dispatch_source_type_signal,
83 _dispatch_source_type_timer, _dispatch_source_type_vnode, _dispatch_source_type_write,
84 DISPATCH_API_VERSION,
85};
86pub use self::group::{DispatchGroup, DispatchGroupGuard};
87pub use self::io::{
88 DispatchIO, DispatchIOCloseFlags, DispatchIOIntervalFlags, DispatchIOStreamType,
89};
90#[cfg(feature = "objc2")]
91pub use self::main_thread_bound::{run_on_main, MainThreadBound};
92pub(crate) use self::object::dispatch_object_s;
93pub use self::object::{
94 DispatchObject, DispatchQoS, QualityOfServiceClassFloorError, QOS_MIN_RELATIVE_PRIORITY,
95};
96pub use self::once::DispatchOnce;
97pub use self::queue::{
98 dispatch_main, DispatchQueue, DispatchQueueAttr, DispatchQueueGlobalPriority,
99 GlobalQueueIdentifier, QueueAfterError,
100};
101pub use self::retained::DispatchRetained;
102pub use self::semaphore::{DispatchSemaphore, DispatchSemaphoreGuard};
103pub use self::source::{
104 dispatch_source_mach_recv_flags_t, dispatch_source_mach_send_flags_t,
105 dispatch_source_memorypressure_flags_t, dispatch_source_proc_flags_t,
106 dispatch_source_timer_flags_t, dispatch_source_type_s, dispatch_source_type_t,
107 dispatch_source_vnode_flags_t, DispatchSource,
108};
109pub use self::time::DispatchTime;
110pub use self::workloop::DispatchWorkloop;
111
112type OpaqueData = UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>;
114
115#[deprecated = "renamed to DispatchGroup"]
117pub type Group = DispatchGroup;
118
119#[deprecated = "renamed to DispatchOnce"]
121pub type Once = DispatchOnce;
122
123#[deprecated = "renamed to DispatchQueue"]
125pub type Queue = DispatchQueue;
126
127#[deprecated = "renamed to DispatchSemaphore"]
129pub type Semaphore = DispatchSemaphore;
130
131#[deprecated = "renamed to DispatchWorkloop"]
133pub type WorkloopQueue = DispatchWorkloop;
134
135#[cfg_attr(target_vendor = "apple", link(name = "System", kind = "dylib"))]
136#[cfg_attr(not(target_vendor = "apple"), link(name = "dispatch", kind = "dylib"))]
137extern "C" {}
138
139#[allow(non_camel_case_types)]
145pub type dispatch_function_t = extern "C" fn(*mut core::ffi::c_void);