mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
add: [ipc] operation declaration for event object
This commit is contained in:
parent
f657fd1c7e
commit
5dc436e047
46
include/libipc/event.h
Normal file
46
include/libipc/event.h
Normal 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_
|
||||
7
test/ipc/test_ipc_event.cpp
Normal file
7
test/ipc/test_ipc_event.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <libipc/event.h>
|
||||
|
||||
TEST(event, open_close) {
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user