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 to 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.

Collectd PostgreSQL Plugin

I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresql