what contract supposed iconnectableobservable.connect when it's called more once?
when idisposable returned disposed of should oncompleted published or should disconnect , allow connect called second time?
if connect called second time before first disposed of, should it:
- throw
- return same idisposable, possibly having unexpected dispose different regions of code
- return new idisposable sort of dispose reference counting , cause issues source called dispose on still publishing values
i'm trying implement iconnectableobservable , documentation people implementing light.
if have @ source
the answer first question (as of writing):
when idisposable returned disposed of should oncompleted published or should disconnect , allow connect called second time?
just disconnects
if connect called second time before first disposed of
it should: return same idisposable, possibly having unexpected dispose different regions of code
for posterity sake interesting code sections are:
public void dispose() { lock (_parent._gate) { if (_subscription != null) { _subscription.dispose(); _subscription = null; _parent._connection = null; } } }
and
public idisposable connect() { lock (_gate) { if (_connection == null) { var subscription = _source.subscribesafe(_subject); _connection = new connection(this, subscription); } return _connection; } }
as can see in above there single connection disposed , connected within lock block prevent concurrent modification.
Comments
Post a Comment