Enable proper full C++ exception handling on MSVC
[openal-soft.git] / core / async_event.h
blobf865fd8a809b3a054b5a841813d8656655a0a733
1 #ifndef CORE_EVENT_H
2 #define CORE_EVENT_H
4 #include <array>
5 #include <cstdint>
6 #include <string>
7 #include <variant>
9 #include "almalloc.h"
11 struct EffectState;
13 using uint = unsigned int;
16 enum class AsyncEnableBits : std::uint8_t {
17 SourceState,
18 BufferCompleted,
19 Disconnected,
20 Count
24 enum class AsyncSrcState : std::uint8_t {
25 Reset,
26 Stop,
27 Play,
28 Pause
31 using AsyncKillThread = std::monostate;
33 struct AsyncSourceStateEvent {
34 uint mId;
35 AsyncSrcState mState;
38 struct AsyncBufferCompleteEvent {
39 uint mId;
40 uint mCount;
43 struct AsyncDisconnectEvent {
44 std::string msg;
47 struct AsyncEffectReleaseEvent {
48 EffectState *mEffectState;
51 using AsyncEvent = std::variant<AsyncKillThread,
52 AsyncSourceStateEvent,
53 AsyncBufferCompleteEvent,
54 AsyncEffectReleaseEvent,
55 AsyncDisconnectEvent>;
57 template<typename T, typename ...Args>
58 auto &InitAsyncEvent(std::byte *evtbuf, Args&& ...args)
60 auto *evt = al::construct_at(reinterpret_cast<AsyncEvent*>(evtbuf), std::in_place_type<T>,
61 std::forward<Args>(args)...);
62 return std::get<T>(*evt);
65 #endif