add: [ipc] operation declaration for event object

This commit is contained in:
mutouyun 2023-07-23 18:44:01 +08:00
parent f657fd1c7e
commit 5dc436e047
2 changed files with 53 additions and 0 deletions

46
include/libipc/event.h Normal file
View File

@ -0,0 +1,46 @@
/**
* \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 Create a new event object with a name.
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 one of the specified event objects is in the signaled state.
LIBIMP_EXPORT ::LIBIMP::result<bool> evt_wait(evt_t, std::int64_t ms) noexcept;
LIBIMP_EXPORT ::LIBIMP::result<bool> evt_wait(::LIBIMP::span<evt_t>, std::int64_t ms) noexcept;
/**
* \brief The event object.
*/
class LIBIMP_EXPORT event {
evt_t evt_;
};
LIBIPC_NAMESPACE_END_

View File

@ -0,0 +1,7 @@
#include "gtest/gtest.h"
#include <libipc/event.h>
TEST(event, open_close) {
}