Mercurial Hosting > luan
changeset 1851:9d093f14e240 default tip
clear global_callables on site close
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 22 Feb 2025 23:38:40 -0700 |
parents | 64b7076c635c |
children | |
files | src/luan/modules/ThreadLuan.java |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
diff -r 64b7076c635c -r 9d093f14e240 src/luan/modules/ThreadLuan.java --- a/src/luan/modules/ThreadLuan.java Sat Feb 22 20:26:31 2025 -0700 +++ b/src/luan/modules/ThreadLuan.java Sat Feb 22 23:38:40 2025 -0700 @@ -162,12 +162,21 @@ } } - public static synchronized Callable globalCallable(String name,LuanFunction initFn,long timeout) throws LuanException { + public static synchronized Callable globalCallable(Luan luan,final String name,LuanFunction initFn,long timeout) throws LuanException { Callable callable = callableMap.get(name); if( callable == null ) { sweep(); callable = new Callable(initFn); callableMap.put(name,callable); + Closeables cs = (Closeables)luan.registry().get(CLOSEABLES); + if( cs != null ) { + Closeable cl = new Closeable() { + public void close() { + removeGlobalCallable(name); + } + }; + cs.addCloseable(cl); + } } callable.expires = System.currentTimeMillis() + timeout; return callable;