Mercurial Hosting > luan
comparison src/luan/modules/ThreadLuan.java @ 1599:f2a663a4ba9e
web logging
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 05 Apr 2021 00:13:05 -0600 |
parents | c922446f53aa |
children | 7c7f28c724e8 |
comparison
equal
deleted
inserted
replaced
1598:c78d6a4e2d9a | 1599:f2a663a4ba9e |
---|---|
80 { | 80 { |
81 options = new LuanTable(options); | 81 options = new LuanTable(options); |
82 Number delay = Utils.removeNumber(options,"delay"); | 82 Number delay = Utils.removeNumber(options,"delay"); |
83 Number repeatingDelay = Utils.removeNumber(options,"repeating_delay"); | 83 Number repeatingDelay = Utils.removeNumber(options,"repeating_delay"); |
84 Number repeatingRate = Utils.removeNumber(options,"repeating_rate"); | 84 Number repeatingRate = Utils.removeNumber(options,"repeating_rate"); |
85 Boolean dontGc = Utils.removeBoolean(options,"dont_gc"); | |
85 String id = Utils.removeString(options,"id"); | 86 String id = Utils.removeString(options,"id"); |
86 if( repeatingDelay!=null && repeatingRate!=null ) | 87 if( repeatingDelay!=null && repeatingRate!=null ) |
87 throw new LuanException("can't define both repeating_delay and repeating_rate"); | 88 throw new LuanException("can't define both repeating_delay and repeating_rate"); |
88 boolean repeating = repeatingDelay!=null || repeatingRate!=null; | 89 boolean repeating = repeatingDelay!=null || repeatingRate!=null; |
89 Utils.checkEmpty(options); | 90 Utils.checkEmpty(options); |
106 sf = scheduler.schedule(r,delay.longValue(),TimeUnit.MILLISECONDS); | 107 sf = scheduler.schedule(r,delay.longValue(),TimeUnit.MILLISECONDS); |
107 } else { | 108 } else { |
108 scheduler.schedule(r,0L,TimeUnit.MILLISECONDS); | 109 scheduler.schedule(r,0L,TimeUnit.MILLISECONDS); |
109 return; | 110 return; |
110 } | 111 } |
111 Object c = new Object() { | 112 if( !Boolean.TRUE.equals(dontGc) ) { |
112 protected void finalize() throws Throwable { | 113 Object c = new Object() { |
113 cancel(sf,"gc"); | 114 protected void finalize() throws Throwable { |
114 } | 115 cancel(sf,"gc"); |
115 }; | 116 } |
116 luan.registry().put(c,c); // cancel on gc | 117 }; |
118 luan.registry().put(c,c); // cancel on gc | |
119 } | |
117 if( id != null ) | 120 if( id != null ) |
118 scheduleds.put(id,sf); | 121 scheduleds.put(id,sf); |
119 } | 122 } |
120 | 123 |
121 | 124 |