[GOODIE] LindaTalk update: they now support an event model Challenge: make it fast!

Rob Withers slosher2 at home.com
Fri Jul 28 09:53:20 UTC 2000


Hi all,

Attached you will find an updated LindaTalk.  Try the Dining Philosopher
example that Bolot did once upon a time.  Very neat!  I removed the
naming of tuple fields for performance and complexity reasons, so the
Core framework is practically unchanged from 6 months ago.  You will
find the EventTupleSpace subclass, which allows you to register for
callback events if certain operations occur.   You can dynamically
change the number of Processes which dispatch events by sending
#threadPoolSize: aNum to the EventTupleSpace. 

I would like to issue a challenge to see if we can't get the performance
up.  It is currently averaging about 70 reads and writes of tuples a
second.  There are performance tests in the Workspace that pops up when
you install.

I have a few ideas about using a binary search tree with these tuples,
so that each node will have one of the fields from the tuple, and a
tuple would describe a path in the tree.  Another idea is to have a
restricted TupleSpace which would use hashes and IdentityDictionaries to
match Tuples.  You could label some of the fields as being Symbols so
that the comparison is faster.  Finally, writting a Plugin may make some
sense.

How to use regular LindaTalk:
For reading and writing:
	| ts |
	ts := TupleSpace new.
	 "stores this tuple"
	ts add: ('Psst' | 'Squeak Rulez!'). 
	"only unlocks synchronous reads and takes"
	ts transientAdd: ('Psst' | 'Squeak Rulez!'). 
	"read but leave it there - non-blocking" 
	ts detect: ('Psst' | String).  
	"take the tuple - non-blocking"
	ts remove: ('Psst' | String).  
	ts detect: ('Psst' | String)
		ifNone: [nil].
	ts remove: ('Psst' | String)
		ifNone: [nil].
	"blocking read"
	ts syncDetect: ('Psst' | String).  
	"blocking take"
	ts syncRemove: ('Psst' | String).  

How to register for events.  Normally you send #when:send:to:.   You can
register for normal events the same way, of course.  To register for
Tuple activity, we need to register for an event with a matching tuple
and then an action.  So we have  
	#when:match:send:to:
logic.   The match argument is a tuple.
	| ts |
	ts := EventTupleSpace new.
	 "register for events"
	ts 
		when: #write 
		match: ('Psst' | String) 
		send: #beep 
		to: Smalltalk.

	"This will beep us"
	ts add: ('Psst' | 'Squeak Rulez!'). 


enjoy!
Rob


-- 
--------------------------------------------------
Smalltalking by choice.  Isn't it nice to have one!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: linda-events-a1.tgz
Type: application/octet-stream
Size: 18224 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20000728/cb9c9ad9/linda-events-a1.obj


More information about the Squeak-dev mailing list