Status of Async/AFF implementation #114
Replies: 4 comments 1 reply
|
Hi @ngenovese11, we use echo-processes in a huge environment. We run thousands of actors in parallel. The original version used a pausable-blocking-queue implementation which caused two real threads (i.e. The Async + Aff rewrite did not use real threads anymore. Instead, it used tasks from TPL. However TPL uses Because of this limit the Async + Aff rewrite was deadlocking if we tried to run more processes. A fix was not trivial so the decision was made to revert the version back to use real threads until we find a fix. So far I haven't got time to look at it again. |
|
@StanJav's answer is correct. The full implementation of the effect system into echo requires an almost full rewrite which is painful. The approach taken lead to unintended consequences and so was rolled back. I have some ideas for a less extreme approach, but not the time to do it currently. You can however roll your own wrappers for your inbox and state functions (that are passed to The following (untested!) utility functions allow you to wrap public static class Async
{
public static Func<S> Setup<S>(Func<Task<S>> setup) =>
() =>
{
S state = default;
Exception err = null;
using (var wait = new AutoResetEvent(false))
{
setup().ContinueWith(t =>
{
if (t.IsFaulted)
{
err = t.Exception;
}
else
{
state = t.Result;
}
wait.Set();
});
wait.WaitOne();
}
if (err != null)
{
ExceptionDispatchInfo.Capture(err).Throw();
}
return state;
};
public static Func<S, A, S> Inbox<S, A>(Func<S, A, Task<S>> inbox) =>
(s, m) =>
{
Exception err = null;
using (var wait = new AutoResetEvent(false))
{
inbox(s, m).ContinueWith(t =>
{
if (t.IsFaulted)
{
err = t.Exception;
}
else
{
s = t.Result;
}
wait.Set();
});
wait.WaitOne();
}
if (err != null)
{
ExceptionDispatchInfo.Capture(err).Throw();
}
return s;
};
} |
|
Yes full re-write sounds painful; thanks for the insight. I have some tests going with some TPL refactors (specifically changes in the BlockingQueues), but not at the scale noted above. In the meantime everything is functional and I can work around it with various versions of the wrappers noted above. Thanks a lot for the responses! |
|
Support is now in https://github.com/louthy/echo-process/releases/tag/v2.2.0-beta |
Uh oh!
There was an error while loading. Please reload this page.
Hello and thanks for this awesome library. I see in the history some attempts to implement Async and AFF actors that appear to have been reverted. I have a need for some projects and am happy to take up the effort, but would love some insight into why the changes were abandoned.
All reactions