Die4Ever / Die4Ever/AsyncGameEngine

global message queue vs per process?

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

a global message queue would be a circular buffer of MessageBlocks, like this

class MessageBlock {
atomic \ num_read=0;
vector \ messages;
};

aligned to cache lines? an ID number for the block?

when a process reads the block of messages, increment the num_read variable, when it reaches the number of running processes then that message can be overwritten

will need an atomic\ for the end, add to this when writing a new block of messages

don't think I need a marker for the start since each process will remember where it last read

when a process is created or killed, send a ping message or a ProcessCreated/ProcessClosed message and when that message has num_read==open_processes then you know everything is caught up

pros: less cache pollution, less strain on memory bandwidth, less work for the engine not having to duplicate messages for each process or check which processes care about which messages, messages sent to the engine won't have to be reflected out to other processes

cons: more synchronization, a slow process could cause the buffer to fill up, circular buffer with variable length items is complicated

could also categorize messages for a few separate queues? use a bloom filter for the whole queue?

if I need a read/write lock, I can simply use an atomic\, just increment by 1 to add a reader, increment by 9999999 to add a writer

every message might need an ID to handle responses? or maybe only do it for specific messages that need it? will they need from_process_id? from_process_id could be for the whole block instead of per message

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.