[Pharo-project] is there a way to know whether an object is registered to an announcer?
On 23 April 2011 13:58, Stéphane Ducasse <Stephane.Ducasse@inria.fr> wrote:
hi guys
is there  a way to know whether an object is registered to an announcer?
I propose
isRegistering: anObject
registry subscriptionsOf: anObject  do: [:each | ^ true]. ^ false
then more appropriate would be #hasSubscriber: May i ask why you need to test it? Usually you don't need to test who subscribed to what. And if you do, then i suspect there are some design mistake. -- Best regards, Igor Stasenko AKA sig.
hi guys
is there a way to know whether an object is registered to an announcer?
I propose
isRegistering: anObject
registry subscriptionsOf: anObject do: [:each | ^ true]. ^ false
then more appropriate would be #hasSubscriber:
yes much better.
May i ask why you need to test it?
sure I'm trying to understand why I have 6 instances of RPackageOrganizer and also the code of cyrille. So knowing if a given instance is registered is important for me to debug and also to write some tests.
Usually you don't need to test who subscribed to what. And if you do, then i suspect there are some design mistake.
Exactly, still the API should let me do what I have to do when I need it. Stef
-- Best regards, Igor Stasenko AKA sig.
On 23 April 2011 21:24, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
hi guys
is there  a way to know whether an object is registered to an announcer?
I propose
isRegistering: anObject
registry subscriptionsOf: anObject  do: [:each | ^ true]. ^ false
then more appropriate would be #hasSubscriber:
yes much better.
May i ask why you need to test it?
sure I'm trying to understand why I have 6 instances of RPackageOrganizer and also the code of cyrille. So knowing if a given instance is registered is important for me to debug and also to write some tests.
Usually you don't need to test who subscribed to what. And if you do, then i suspect there are some design mistake.
Exactly, still the API should let me do what I have to do when I need it.
Okay. But i would discourage from using such methods :)
Stef
-- Best regards, Igor Stasenko AKA sig.
-- Best regards, Igor Stasenko AKA sig.
Yes Now is there a way that we could make sure that an object is really unregistered? I would write [ann hasSubscriber: anObject] whileTrue: [an unregister: anObject] in the client code but having fullyUnregister: anObject is good to have in special case. Stef
Okay. But i would discourage from using such methods :)
Stef
-- Best regards, Igor Stasenko AKA sig.
-- Best regards, Igor Stasenko AKA sig.
Why #unregister: is not enough? 2011/4/24 Stéphane Ducasse <stephane.ducasse@inria.fr>
Yes
Now is there a way that we could make sure that an object is really unregistered? I would write
[ann hasSubscriber: anObject] whileTrue: [an unregister: anObject] in the client code but having
fullyUnregister: anObject
is good to have in special case.
Stef
Okay. But i would discourage from using such methods :)
Stef
-- Best regards, Igor Stasenko AKA sig.
-- Best regards, Igor Stasenko AKA sig.
ok I was not aware that the semantics was what I was looking for.... the comment is so good also. removeSubscriber: subscriber ^ self protected: [ subscriptions removeAllSuchThat: [:subscription | subscription subscriber == subscriber ]] On Apr 24, 2011, at 11:02 AM, Denis Kudriashov wrote:
Why #unregister: is not enough?
2011/4/24 Stéphane Ducasse <stephane.ducasse@inria.fr> Yes
Now is there a way that we could make sure that an object is really unregistered? I would write
[ann hasSubscriber: anObject] whileTrue: [an unregister: anObject] in the client code but having
fullyUnregister: anObject
is good to have in special case.
Stef
Okay. But i would discourage from using such methods :)
Stef
-- Best regards, Igor Stasenko AKA sig.
-- Best regards, Igor Stasenko AKA sig.
of course if the method would have been commented like that I would not have asked. So I'm doing a pass on the class now and adding comments :( unsubscribe: anObject "Unsubscribe all occurrences of the subscriber anObject" registry removeSubscriber: anObject On Apr 24, 2011, at 11:02 AM, Denis Kudriashov wrote:
Why #unregister: is not enough?
2011/4/24 Stéphane Ducasse <stephane.ducasse@inria.fr> Yes
Now is there a way that we could make sure that an object is really unregistered? I would write
[ann hasSubscriber: anObject] whileTrue: [an unregister: anObject] in the client code but having
fullyUnregister: anObject
is good to have in special case.
Stef
Okay. But i would discourage from using such methods :)
Stef
-- Best regards, Igor Stasenko AKA sig.
-- Best regards, Igor Stasenko AKA sig.
On 24 April 2011 12:08, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
of course if the method would have been commented like that I would not have asked. So I'm doing a pass on the class now and adding comments :(
unsubscribe: anObject     "Unsubscribe all occurrences of the subscriber anObject"
"Unsubscribe all subscriptions of anObject from receiver"
    registry removeSubscriber: anObject
Hmm.. isn't that was obvious? I mean, what behavior you found less surprising? Removing single subscription per call? Which one? In what order? -- Best regards, Igor Stasenko AKA sig.
On Apr 24, 2011, at 11:54 AM, Igor Stasenko wrote:
On 24 April 2011 12:08, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
of course if the method would have been commented like that I would not have asked. So I'm doing a pass on the class now and adding comments :(
unsubscribe: anObject "Unsubscribe all occurrences of the subscriber anObject"
"Unsubscribe all subscriptions of anObject from receiver"
registry removeSubscriber: anObject
Hmm.. isn't that was obvious?
No idea. Nothing is obvious!!! Comments are there to remove the obvious assumptions. Stef
I mean, what behavior you found less surprising? Removing single subscription per call? Which one? In what order?
-- Best regards, Igor Stasenko AKA sig.
weak "announcer weak subscribe: foo" ^ WeakSubscriptionBuilder on: self What could be the comment? Stef
On 24 April 2011 13:16, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
weak     "announcer weak subscribe: foo"     ^ WeakSubscriptionBuilder on: self
What could be the comment?
answer a receiver's proxy which can be used for subscribing using weak subscriptions.
Stef
-- Best regards, Igor Stasenko AKA sig.
Is the expected number of registered objects be such that for present platform performance the O(n) worst case time to know the answer is OK? my 0.019999... -- Cesar Rabak Em 23/04/2011 07:58, Stéphane Ducasse < Stephane.Ducasse@inria.fr > escreveu: hi guys is there  a way to know whether an object is registered to an announcer? I propose isRegistering: anObject registry subscriptionsOf: anObject  do: [:each | ^ true]. ^ false stef
participants (5)
-
csrabak@bol.com.br -
Denis Kudriashov -
Igor Stasenko -
Stéphane Ducasse -
Stéphane Ducasse