Skip to content

Commit 24e9f06

Browse files
committed
Add x_set_extend_daemon_manager
Update README
1 parent 3ce6945 commit 24e9f06

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ Swaps one procedure for another (or given closure) in a saved environment
4242
## Global
4343
A set of functions for globals
4444

45+
### void x_set_extend_daemon_manager():
46+
Sets extend daemon manager, that clearing globals when threads deactivated.
47+
48+
### void x_set_auto_globals(auto):
49+
ets automatically initialize globals for new threads.
50+
4551
### boolean is\_auto\_globals():
4652
Returns whether globals for threads are automatically initialized.
4753

src/main/java/me/anatoliy57/chunit/functions/Global.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,53 @@ public Boolean runAsync() {
337337
}
338338
}
339339

340+
@api
341+
public static class x_set_extend_daemon_manager extends AbstractFunction {
342+
343+
public x_set_extend_daemon_manager() {
344+
}
345+
346+
public String getName() {
347+
return "x_set_extend_daemon_manager";
348+
}
349+
350+
public Integer[] numArgs() {
351+
return new Integer[]{0};
352+
}
353+
354+
public String docs() {
355+
return "void {} Sets extend daemon manager, that clearing globals when threads deactivated.";
356+
}
357+
358+
public Class<? extends CREThrowable>[] thrown() {
359+
return new Class[]{};
360+
}
361+
362+
public boolean isRestricted() {
363+
return true;
364+
}
365+
366+
public MSVersion since() {
367+
return MSVersion.V3_3_4;
368+
}
369+
370+
public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException {
371+
synchronized (Globals.class) {
372+
DaemonManager daemonManager = ReflectionUtils.GetDaemonManager(env);
373+
if (!(daemonManager instanceof ExtendDaemonManager)) {
374+
ExtendDaemonManager extendManager = new ExtendDaemonManager(daemonManager, false);
375+
ReflectionUtils.SetDaemonManager(env, extendManager);
376+
}
377+
}
378+
379+
return CVoid.VOID;
380+
}
381+
382+
public Boolean runAsync() {
383+
return null;
384+
}
385+
}
386+
340387
@api
341388
public static class x_set_auto_globals extends AbstractFunction {
342389

0 commit comments

Comments
 (0)