dispatch: add dispatch_source, dispatch_queue
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
ac9ba6919a
commit
1a8ab33ecc
42
include/MacStd/dispatch.hpp
Normal file
42
include/MacStd/dispatch.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
SPDX-License-Identifier: MIT
|
||||
Copyright © 2025 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common.hpp"
|
||||
#include <dispatch/dispatch.h>
|
||||
|
||||
namespace macstd {
|
||||
///
|
||||
/// Dispatch object traits
|
||||
///
|
||||
struct dispatch_traits
|
||||
{
|
||||
static inline constexpr dispatch_source_t invalid = static_cast<dispatch_source_t>(NULL);
|
||||
|
||||
///
|
||||
/// Decrements the reference count (the retain count) of a dispatch object
|
||||
///
|
||||
/// \sa [dispatch_release function](https://developer.apple.com/documentation/dispatch/1496328-dispatch_release)
|
||||
///
|
||||
static void free(dispatch_source_t h) noexcept
|
||||
{
|
||||
dispatch_release(h);
|
||||
}
|
||||
|
||||
private:
|
||||
static dispatch_source_t duplicate(dispatch_source_t h);
|
||||
};
|
||||
|
||||
///
|
||||
/// Dispatch event source
|
||||
///
|
||||
using dispatch_source = handle<dispatch_source_t, dispatch_traits>;
|
||||
|
||||
///
|
||||
/// Dispatch event source
|
||||
///
|
||||
using dispatch_queue = handle<dispatch_queue_t, dispatch_traits>;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user