Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Pausing threads in Tango

Moderators: larsivi kris

Posted: 06/22/07 23:03:06

Hello,

Being somewhat of a convert to Tango, I was disappointed that the Phobos to Tango migration page said that using Thread.pause() is dangerous and therefore unimplemented. I need the Thread.pause() functionality to pause threads and look at what they're doing (and if that sounds dangerous, it is :P). Arbitrary thread pausing is also useful for implementing task scheduling (i.e. green threading etc.) and garbage collection.

I don't particularly wish to mix Tango *threads* with OS-specific calls to pause threads - so I was wondering how thread pausing could be done otherwise? :P

Vladimir

http://www.vladsharp.com - The Crests of Reason

Author Message

Posted: 06/23/07 00:14:25

Yes, Thread.suspend() and its bretheren were removed because any use outside of something pretty specialized like an in process debugger is probably an incorrect use of the feature, and risks deadlocking the app. Java deprecated Thread.pause() for the same reason. All that exists now is a routine the GC uses to suspend all threads together (thread_suspendAll), but it sounds like you only want to suspend a single thread? I suppose I could add a specialized routine for this, but one doesn't exist now. The alternative would be to write the C code yourself, which shouldn't actually be very difficult.