This is a mature implementation of periodic task that run a function at given interval. It allows task to be stopped, and deals with edge case like interval too short gracefully. V2Ray/V2Fly is MIT licensed.