[dmd-concurrency] Shutdown protocol

Michel Fortin michel.fortin at michelf.com
Wed Jan 20 10:40:47 PST 2010


Le 2010-01-20 à 12:40, Robert Jacques a écrit :

> I like the updated example, but the updated shutdown protocol sounds like a race waiting to happen. For example, suppose you spawn a thread (A) and send it's tid to another thread (B) and then exit. The spawned thread dies and the other then runs into errors. So now B's racing on A's shutdown event and may have intended behavior one day and then throw a bunch of shutdown exceptions the next.

Indeed. That's a bad thing about it.


> However, expanding on this concept, if tid was ref-counted, shutdown exceptions could be thrown correctly and at least the above race would be avoided.

Although with reference counting two or more threads referencing each other would create circular references and never shutdown. In some cases perhaps that's what you want though, if you use another shutdown mechanism for instance, but you probably don't want this be implicit when creating circular references.


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/





More information about the dmd-concurrency mailing list