dabeaz / thredo

Thredo was an experiment - It's dead. Feel free to look around.
MIT License
338 stars 19 forks source link

The windmills and worms in the mind of threads... #4

Open HarveySummers opened 6 years ago

HarveySummers commented 6 years ago

Wouldn't you want to optionally register one or more callbacks that react to kill command. This would route the kill to a seperate (spawned) thread that would know how to cleanup and cleanly kill the main thread. A "last will and testament" thread could upon startup register its own monitor or a timer to kill itself (thread suicide?).

Also, a theme song? https://www.youtube.com/watch?v=Twix375Me4Q

dabeaz commented 6 years ago

There are probably many ways in which one can manage cancellation. The really big requirement, however, is that when threads are blocked, there needs to be some way to unblock them when cancelled. Thredo minimally provides that so if one were to do something more sophisticated, this would be a starting a point.