Deterministic Collection Using Generics

  • Thread starter Thread starter Jeff Louie
  • Start date Start date
J

Jeff Louie

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
 
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
 
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?<
 
Back
Top