Le 29/8/16 à 21:37, Tudor Girba a écrit :
Hi Denis,
Thanks a lot for this analysis!
In summary, the Bloc events are faster because:
1. they store the subscriptions in OrderedCollection instead of IdentitySet.
This is likely something we can improve in Announcements.
2. they are unsafe.
For 1., the only reason I can think of is to prevent the user to register twice
the same object by mistake. I think this is an optimization that should be the
responsibility of the user.
It depends of the contract.
Since we want to have a solid architecture then it should not be the
responsibility of the client to me.
For 2. the question is if Bloc really does not need the mutex.
Cheers,
Doru
On Aug 29, 2016, at 6:36 PM, Denis Kudriashov <[email protected]> wrote:
And expenses to deliver announcement caused also by protection and usage of
IdentitySet.
Also in announcements we first collect all subscriptions with interest to
separate collection and only after we iterate and process given announcement.
But in Bloc you use #select:thenDo: method instead. It is unsafe because event
handlers can be modified during delivering (by producing new subscriptions or
by unsubscribing inside handlers).
So if you want to address it (and I sure you do) it will lead to same code and
performance of announcements.
2016-08-29 18:05 GMT+02:00 Denis Kudriashov <[email protected]>:
Thank's.
I try tests for subscribing and what I found is:
Main problem that subscriptions inside SubscriptionRegistry are managed as
IdentitySet which of cause much slower for addition then OrderedCollection. We
probably could use OrderedCollection here because items are always created on
fly and identitySet has no sense.
Another problem is access protection by mutex (semaphore) which make it 3 times
slower.
So with OrderedCollection and disabled mutex performance for subscribing is
same.
I pretty sure that protection is required for Block handlers too.
2016-08-29 17:18 GMT+02:00 Glenn Cavarlé <[email protected]>:
Ha... tag doesn't work...
You can load Bloc and show the tests using this script:
Gofer it
smalltalkhubUser: 'Pharo' project: 'Bloc';
configuration;
loadDevelopment.
Gofer it
smalltalkhubUser: 'Pharo' project: 'Bloc';
package: 'Bloc-Tests';
load.
BlAnnouncerVsBlEventRegistryTest browse
-----
Glenn Cavarlé
--
View this message in context:
http://forum.world.st/About-the-non-use-of-Announcer-in-Bloc-tp4913008p4913088.html
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
--
www.tudorgirba.com
www.feenk.com
"Every successful trip needs a suitable vehicle."