From 1a8ab33ecc61eb52551088d2ada98cdc0889a250 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 20 Jun 2025 10:24:20 +0200 Subject: [PATCH] dispatch: add dispatch_source, dispatch_queue Signed-off-by: Simon Rozman --- include/MacStd/dispatch.hpp | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 include/MacStd/dispatch.hpp diff --git a/include/MacStd/dispatch.hpp b/include/MacStd/dispatch.hpp new file mode 100644 index 0000000..5905f44 --- /dev/null +++ b/include/MacStd/dispatch.hpp @@ -0,0 +1,42 @@ +/* + SPDX-License-Identifier: MIT + Copyright © 2025 Amebis +*/ + +#pragma once + +#include "common.hpp" +#include + +namespace macstd { + /// + /// Dispatch object traits + /// + struct dispatch_traits + { + static inline constexpr dispatch_source_t invalid = static_cast(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 event source + /// + using dispatch_queue = handle; +}