471,310 Members | 1,024 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

Deterministic Collection Using Generics

Here is my try at generics. This creates a collection that implements
IInvoke and IDisposable and Adds types that implement IInvoke and
IDisposable. When the collection goes out of using scope dispose is
called on all members of the collection. Calling Invoke on the
collection calls Invoke on each member of the collection.

http://www.geocities.com/jeff_louie/oop29.htm

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Dec 17 '05 #1
3 1114
Jeff,

It appears the JALGenericCollection<T> and JALCollection objects were
intended to be thread-safe, but they're not quite there yet. The
problem is with the Dispose method and the checks at the beginning of
Add, Clear, and Invoke to see if the object has been disposed.
Synchronization has not be applied correctly to prevent one thread from
calling Dispose while another calls Invoke after the object has been
disposed.

Aren't generics a great addition to the language?

Brian

Jeff Louie wrote:
Here is my try at generics. This creates a collection that implements
IInvoke and IDisposable and Adds types that implement IInvoke and
IDisposable. When the collection goes out of using scope dispose is
called on all members of the collection. Calling Invoke on the
collection calls Invoke on each member of the collection.

http://www.geocities.com/jeff_louie/oop29.htm

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***


Dec 17 '05 #2
Brian...Thanks for the tip. My old brain is having trouble learning
thread safety. I moved the disposed clause inside the locks. Does this
look correct now?

http://www.geocities.com/jeff_louie/oop29.htm

You may need to refresh the page load. And yes, Generics are cool.

Regards,
Jeff
It appears the JALGenericCollection<T> and JALCollection objects were

intended to be thread-safe, but they're not quite there yet. The problem
is with the Dispose method and the checks at the beginning of Add,
Clear, and Invoke to see if the object has been disposed.
Synchronization has not be applied correctly to prevent one thread from
calling Dispose while another calls Invoke after the object has been
disposed.

Aren't generics a great addition to the language?<
*** Sent via Developersdex http://www.developersdex.com ***
Dec 18 '05 #3

Jeff Louie wrote:
Brian...Thanks for the tip. My old brain is having trouble learning
thread safety. I moved the disposed clause inside the locks. Does this
look correct now?

http://www.geocities.com/jeff_louie/oop29.htm


It looks correct now. Thread-safety is tricky to get right.

Brian

Dec 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Michael D. Ober | last post: by
3 posts views Thread by Michael Fällgreen | last post: by
8 posts views Thread by JAL | last post: by
4 posts views Thread by Robert Schneider | last post: by
14 posts views Thread by cwineman | last post: by
8 posts views Thread by Mike P | last post: by
7 posts views Thread by =?Utf-8?B?Q29kZVJhem9y?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.