Wednesday, August 27, 2014

Really stop Clojure's infinite loop future with future-cancel

If you like me, executed future-cancel and the future is still running. This blog post is for you.

I suppose your code is something similar too this:
(def f (future (while true (your-function ... ))))
(future-cancel f)
All you have to do as describe in this SO comment is to replace true with (not (Thread/interrupted)). Example:
(future (while (not (Thread/interrupted)) (your-function ... )))
Because future-cancel will send interrupt signal to the future, Thread/interrupted will be changed to true. Now your future-cancel should work as expected.


Handy note from The Future of Ruby Performance Tooling talk

GoRuCo 2014 - The Future of Ruby Performance Tooling by Aaron Quint

It introduces a few numbers of promising Ruby performance tooling. I'll definitely refer back to this post when I do performance optimization.

Config number of file descriptors on Linux

Check file descriptor limit for a process. Vary depending on owner of the process $ cat /proc/{process-id}/limits Check current number of...