Good day.
I have a TPL Dataflow mesh for rpc calls
It has two unkinked flows which in simplified way looks like this:
Output flow:
- BlockBuffer to store output
- ActionBLock to send output to server and produce sent id
And input flow:
- while loop to recieve data
- TransformBlock to parse data
- BlockBuffer to save answer with sentid
there is a problem: when i make calls from separate threads i can mess with answers, so i need to filter it.
my rpc call:
public async Task<RpcAnswer> PerformRpcCall(Call rpccall)
{
...
_outputRpcCalls.Post(rpccall);
long uniqueId = GetUniq(); // call unique id
...
var sent = new Tuple<long, long>(uniqueId, 0);
while (_sentRpcCalls.TryReceive(u => u.Item1 == uniqueId, out sent)) ; // get generated id from send function
return await _inputAnswers.ReceiveAsync(TimeSpan.FromSeconds(30));
}
as you can see i have uniqueId which can help me to determine answer for this call, but how can i filter it and await for it?
Is it good way to have some array of buffers (WriteOnceBlock maybe?) which will be created in rpc call and LinkedTo with filter?