mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-15 09:25:37 +02:00
Implement minetest.ipc_poll()
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user