Mercurial Hosting > luan
changeset 1233:3fad7091b419
make Thread.safe implicit
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 08 Apr 2018 01:01:48 -0600 |
parents | 857eb648d4e5 |
children | 7e7c2d0c3b99 |
files | conv.txt src/luan/modules/Thread.luan |
diffstat | 2 files changed, 17 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/conv.txt Sun Apr 08 00:41:44 2018 -0600 +++ b/conv.txt Sun Apr 08 01:01:48 2018 -0600 @@ -1,3 +1,6 @@ +"Thread.safe" + + "Http.uncache_site" "full_path" "Http.version"
--- a/src/luan/modules/Thread.luan Sun Apr 08 00:41:44 2018 -0600 +++ b/src/luan/modules/Thread.luan Sun Apr 08 01:01:48 2018 -0600 @@ -4,15 +4,15 @@ local error = Luan.error local set_metatable = Luan.set_metatable or error() local try = Luan.try or error() +local Logging = require "luan:logging/Logging.luan" +local logger = Logging.logger "Thread" local Thread = {} -Thread.fork = ThreadLuan.fork -Thread.schedule = ThreadLuan.schedule Thread.sleep = ThreadLuan.sleep -function Thread.safe(fn,logger) +local function safe(fn) return function() try { function() @@ -25,6 +25,17 @@ end end +function Thread.fork(fn,...) + fn = safe(fn) + ThreadLuan.fork(fn,...) +end + +function Thread.schedule(delay,repeated,fn,...) + fn = safe(fn) + ThreadLuan.schedule(delay,repeated,fn,...) +end + + --[[ Thread.global = {} -- shared across threads local map = ThreadLuan.GlobalMap.new()