I am struggling to find solutions to a problem that I encounter in a concurrent system (I am currently using the Actor Model). I basically have a diamond structure of actors:
D sends messages to
B, which consequently send messages to
A. Each part performs some form of operation upon receiving a message.
As an example, define some arbitrary operations, e.g.:
- D: Generate random number
- C: Apply f(x) = x - 1
- B: Apply f(x) = 2x
- A: Apply f(c, b) = (c + b) / 2, where c,b are the results of
A applies its operation, it publishes the result. I now want
A to only publish a result, if it has received the result from both
C for a particular message from
D. So if we would have an incremental index i and generate numbers x_i, I only want
A to operate on c_k, b_j if k == j.
One property of my system that makes this problem quite a bit harder is the existence of throttling. The operations can be costly and/or the frequency with which
D sends messages can be high, so in order to prevent queues from growing infinitely, this seems necessary. It appears to me that this would eliminate any solutions of the form "mark the message from
D and only execute in
A if it has received 2 messages with the same mark", as I can not guarantee to ever receive those 2 messages.
My experience in this area is fairly limited, so any resources or patterns that deal with a similar problem like this would be helpful.