1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Implement minetest.ipc_poll()

This commit is contained in:
sfan5 2024-05-28 23:04:08 +02:00
parent 72801d0233
commit d2b4c27f21
5 changed files with 61 additions and 0 deletions

View file

@ -48,6 +48,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <optional>
#include <string_view>
#include <shared_mutex>
#include <condition_variable>
class ChatEvent;
struct ChatEventChat;
@ -149,12 +150,17 @@ struct ModIPCStore {
/// RW lock for this entire structure
std::shared_mutex mutex;
/// Signalled on any changes to the map contents
std::condition_variable_any condvar;
/**
* Map storing the data
*
* @note Do not store `nil` data in this map, instead remove the whole key.
*/
std::unordered_map<std::string, std::unique_ptr<PackedValue>> map;
/// @note Should be called without holding the lock.
inline void signal() { condvar.notify_all(); }
};
class Server : public con::PeerHandler, public MapEventReceiver,