use crate::objc::Id;
use core::ffi::{c_char, c_void};
unsafe extern "C" {
fn dispatch_queue_create(label: *const c_char, attr: *const c_void) -> Id;
fn objc_release(obj: Id);
}
#[derive(Debug)]
pub struct Queue(Id);
impl Queue {
pub fn serial(label: &core::ffi::CStr) -> Self {
Self(unsafe { dispatch_queue_create(label.as_ptr(), core::ptr::null()) })
}
#[inline]
pub fn as_ptr(&self) -> Id {
self.0
}
}
impl Drop for Queue {
fn drop(&mut self) {
unsafe { objc_release(self.0) }
}
}
unsafe impl Send for Queue {}
unsafe impl Sync for Queue {}