Mercurial Hosting > luan
comparison src/luan/modules/Thread.luan @ 1241:2b5046cd7963
fix Thread safe()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 21 Jun 2018 22:30:13 -0600 |
parents | 3fad7091b419 |
children | 4f571a974132 |
comparison
equal
deleted
inserted
replaced
1240:354e661dee7f | 1241:2b5046cd7963 |
---|---|
11 local Thread = {} | 11 local Thread = {} |
12 | 12 |
13 Thread.sleep = ThreadLuan.sleep | 13 Thread.sleep = ThreadLuan.sleep |
14 | 14 |
15 local function safe(fn) | 15 local function safe(fn) |
16 return function() | 16 return function(...) |
17 try { | 17 try( { |
18 function() | 18 fn |
19 fn() | |
20 end | |
21 catch = function(e) | 19 catch = function(e) |
22 logger.error(e) | 20 logger.error(e) |
23 end | 21 end |
24 } | 22 }, ... ) |
25 end | 23 end |
26 end | 24 end |
27 | 25 |
28 function Thread.fork(fn,...) | 26 function Thread.fork(fn,...) |
29 fn = safe(fn) | 27 fn = safe(fn) |