Comments (13)
Personally I think this should be an option rather than the default behaviour.
from distributed-process.
There is a PR addressing this issue, and I'm wondering what the purpose of removing the notifications from the mailbox is. Notifications can arrive anytime after unmonitoring, so I don't see how this helps avoiding a message leak.
Moreover, the caller of unmonitor may be interested in handling the notifications after unmonitoring.
from distributed-process.
May you please provide a use case when the caller of unmonitor may be interested in handling monitor notification?
My understanding is that unmonitor is called when you are not interested in the monitored resource anymore? Am I missing something?
from distributed-process.
I have no use case. Just pointing at the fact for others to consider.
from distributed-process.
I think part of the rationale for this is provided the same behaviour as Erlang/OTP. In that case, the unmonitor
call flushes (or there's a flushing variant, I forget which is the case) so you won't get unexpected messages in the mailbox. This is particularly important in stateless gen_server and gen_fsm implementations (e.g., what we do in distributed-process-client-server), where an unexpected monitor signal might trigger a shutdown or restart that we don't actually want, and the server loop and message handling/receiving code are hidden from the caller.
from distributed-process.
In that case, I would find less surprising to offer a variant that does the flushing of monitor notifications. Erlang provides more than one variant at least.
from distributed-process.
Yes @facundominguez that's right, and I agree we should offer a variant rather than changing the current behaviour.
from distributed-process.
Erlang does not flush by default, but as @hyperthunk says, gives you the option to. Makes sense to copy Erlang, with an unmonitorFlush
variant or somesuch.
from distributed-process.
Well, except that Erlang only kept the non-flush variant by default due to backwards compatibility... http://erlang.org/pipermail/erlang-questions/2008-August/037564.html
from distributed-process.
@mboes you're right, I don't think unmonitor\1
is useful unless the calling process is trying to exit quickly. In that case however, it might've made sense at one time to use the non flushing variant, since you'd otherwise have to trawl a potentially very large mailbox to find the monitor signal you're waiting for before you can exit. Yes, I know that exiting while you've got a lot of mail left to process seems unlikely, but once you're in a supervision tree it becomes far more likely.
Now in Erlang this scenario isn't such a big issue, since selective receive using a monitor ref is heavily optimised. The same isn't true for CH, and we haven't even looked at segregating the mailbox by type to reduce the complexity of selective receive, so I think having a variant that doesn't make the caller wait for the monitor ref to arrive possibly does matter here.
from distributed-process.
Would it work to have unmonitor
and unmonitorNoFlush
then? unmonitorNoFlush
would have the current implementation of unmonitor
, and unmonitor
would have the implementation given in #252.
from distributed-process.
It's true that there's a potential performance concern here. But i don't think we should choose the semantics based on the details of how things are implemented today. If one wants to unmonitor and exit quickly soon thereafter, can as well just exit with unmonitoring. So I don't see yet how anyone will ever need unmonitorNoFlush
, but it's possible (I'd say change the behaviour of unmonitor
now, then implement unmonitorNoFlush
only once the need does arise for someone in practice).
IOW I vote for merging @VicNumber21's PR #252 without further ado (modulo any review feedback).
from distributed-process.
Yes okay @mboes, I can't really disagree that we shouldn't choose semantics based on implementation details. And stray monitor signals are a pain, so let's merge #252 then, and address the potential /slowness/ of unmonitor
as and when we need to.
from distributed-process.
Related Issues (20)
- Could not deduce (MonadFail Process) arising from a use of ‘fail’ HOT 1
- whereisRemoteAsync does not work via LAN HOT 1
- maintainance issue w.r.t. STM dependency & GHC version compatibility
- broken link in repo description HOT 3
- Generalize call to take a `Closure (SerializableDict a)`
- Revamp/Update CI
- Revamp CI on distributed-process
- Evaluate CI providers HOT 2
- Would it be possible to send and receive CH messages from potentially untrusted sources HOT 1
- Support for distributed traces
- Revamp docs site on distributed process
- Establish support window & upgrade plan
- Address Intermittently failing tests HOT 1
- Remove rematch dependency in distributed-process-tests
- Build failure with ghc-9.2.4 `Expecting one more argument to ‘TyVarBndr’` HOT 2
- Can’t build with GHC 9.2.5 HOT 1
- No instance for (binary-0.8.5.1:Data.Binary.Class.Binary Main.Message) HOT 1
- New release? HOT 5
- Add LaurentRDC to the hackage maintainers list HOT 3
- Add davidsd and LaurentRDC to hackage maintainers list for `distributed-process-tests` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from distributed-process.