mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-07 01:06:45 +08:00
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
/**
|
|
* \file libipc/event.h
|
|
* \author mutouyun (orz@orzz.org)
|
|
* \brief Defines event objects for cross-process communication.
|
|
*/
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <cstdint>
|
|
|
|
#include "libimp/export.h"
|
|
#include "libimp/result.h"
|
|
#include "libimp/span.h"
|
|
|
|
#include "libipc/def.h"
|
|
|
|
LIBIPC_NAMESPACE_BEG_
|
|
|
|
struct evt_handle;
|
|
using evt_t = evt_handle *;
|
|
|
|
/// \brief Creates or opens a named event object.
|
|
LIBIMP_EXPORT ::LIBIMP::result<evt_t> evt_open(std::string name) noexcept;
|
|
|
|
/// \brief Close the event object.
|
|
LIBIMP_EXPORT ::LIBIMP::result<void> evt_close(evt_t) noexcept;
|
|
|
|
/// \brief Gets the name of the event object based on the event handle.
|
|
/// \return empty string on failure.
|
|
LIBIMP_EXPORT std::string evt_name(evt_t) noexcept;
|
|
|
|
/// \brief Sets the event object to the signaled state.
|
|
LIBIMP_EXPORT ::LIBIMP::result<void> evt_set(evt_t) noexcept;
|
|
|
|
/// \brief Waits until the specified object is in the signaled state or the time-out interval elapses.
|
|
LIBIMP_EXPORT ::LIBIMP::result<bool> evt_wait(evt_t, std::int64_t ms) noexcept;
|
|
|
|
/// \brief Waits until one or all of the specified objects are in the signaled state or the time-out interval elapses.
|
|
LIBIMP_EXPORT ::LIBIMP::result<bool> evt_wait(::LIBIMP::span<evt_t const>, std::int64_t ms) noexcept;
|
|
|
|
/**
|
|
* \brief The event object.
|
|
*/
|
|
class LIBIMP_EXPORT event {
|
|
evt_t evt_;
|
|
};
|
|
|
|
LIBIPC_NAMESPACE_END_
|