Continuations and advanced flow control
ibm.com
ibm.com
However, I think that continuations are still very cool, and are especially cool when they can be serialized or written to disk/transmitted/etc., because this essentially lets you "time/space-shift" your thread/process, since it's just bits.
Right now, "suspending" a process is something that happens when you close your laptop or pause a VM, but I think that being able to do this at a much more fine-grained level of detail is what will allow general cloud-based computation to really take off, because individual threads would be portable across computing environments.
PG has also done some work in this area: http://www.paulgraham.com/avg.html
;playing a song with iTunes
$ ps ax | grep iTunes
401 ?? S 5:29.21 /Applications/iTunes.app/Contents/MacOS/iTunes -psn_0_213044
$ kill -STOP 401
;the song stops playing, and iTunes's CPU usage drops to zero
$ kill -CONT 401
;the song resumes exactly where it was
I've done this to, say, Firefox, and resumed it sometime later with no ill effects that I've been able to detect. (Firefox usually has a secondary Flash plugin process; the interaction between the two when one is suspended is kind of interesting, but seemingly benign.)I've found this useful when I've wanted to throttle some application's CPU/other resource usage (usually on a laptop) but didn't want to completely quit it. Also it's just kind of awesome.
Search for "checkpoint restart" to find some links or start here: http://checkpointing.org/ It's all pretty dated though.
I did some work on it years ago but it's no longer maintained http://www.science.uva.nl/research/scs/Software/ckpt/ckpt.ht...
(I have no idea if pidof is included in OSX. It exists in Debian systems though!)
"lets make a blocking API not block. wait, what? (a practical introduction to continuations)"