copy from project http://swtch.com/libtask/