From: Jean Privat Date: Wed, 17 May 2017 13:53:38 +0000 (-0400) Subject: Merge: lib/popcorn: introduce tasks X-Git-Url: http://nitlanguage.org Merge: lib/popcorn: introduce tasks This PR is based on #2436 ## Popcorn threaded tasks Tasks allow you to execute code in another thread than the app listening loop. Useful when you want to run some tasks periodically. Let's say you want to purge the `downloads/` directory of your app every hour: ~~~nit class PurgeTask super PopTask var dir: String redef fun main do loop dir.rmdir 3600.sleep end end end var app = new App # Register a new task app.register_task(new PurgeTask("downloads/")) # Add your handlers # app.use('/', new MyHandler) # Run the tasks app.run_tasks # Start the app app.listen("0.0.0.0", 3000) ~~~ Pull-Request: #2437 Reviewed-by: Jean Privat --- 6d3a81a7ac5b7d468b3fd740b3ff90a68aa137b8