@david_chisnall@infosec.exchange
Post #4276592
2026-07-31 11:23 UTC
@synlogic4242@social.vivaldi.net @icing@chaos.social
POSIX threads were standardised in 1997. A lot of operating systems didn't even have threads back then, or had cooperative ones only. So I don't blame the standard for getting things wrong. Java came out two years earlier, so gets a similar pass.
I think .NET has the nicest model I've seen for this (though not until .NET Framework 4.0). They have cancellation tokens, which have two handles, one that lets you signal cancellation and another that lets you check for cancellation. This lets you send a fan-out or point-to-point cancellation message. APIs plumb cancellation tokens through, so anything that might need to return early takes a reference to the cancellation token (the transmit handle is referred to as a cancellation token source). At places where it might make sense to cancel, you check the cancellation token. It's cheap (acquire-consistency atomic load), and the cancelled thread gets to decide where to exit.
Replies (0)
No replies.