// The Construct // // Copyright (C) The Construct Developers, Authors & Contributors // Copyright (C) 2016-2023 Jason Volk // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice is present in all copies. The // full license for this software is available in the LICENSE file. #pragma once #define HAVE_IRCD_M_VM_NOTIFY_H namespace ircd::m::vm::notify { struct future; using value_type = std::pair *>; using alloc_type = allocator::node; using map_type = std::multimap *, std::less<>, alloc_type::allocator>; using node_type = std::pair; extern map_type map; size_t wait(const vector_view &, const milliseconds); bool wait(const event::id &, const milliseconds); } class ircd::m::vm::notify::future :public ctx::future<> { node_type node; ctx::promise<> promise; unique_iterator it; public: future(const event::id &); future(future &&) = delete; future(const future &) = delete; }; /// Yields ctx until event was successfully evaluated. Returns false if /// timeout occurred. inline bool ircd::m::vm::notify::wait(const event::id &event_id, const milliseconds to) { const vector_view vector ( &event_id, 1 ); const auto count { wait(vector, to) }; return count; }