01: /*
02: * @(#)init.java 1.4 05/03/18
03: *
04: * Copyright (c) 2001-2004 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package pnuts.multithread;
10:
11: import org.pnuts.multithread._threadPool;
12: import pnuts.lang.Package;
13: import pnuts.lang.Context;
14: import pnuts.ext.ModuleBase;
15:
16: /**
17: * Initialization of the pnuts.multithread module
18: */
19: public class init extends ModuleBase {
20:
21: static String[] files = { "pnuts/multithread/thread",
22: "pnuts/multithread/threadGroup", };
23:
24: static String[][] functions = {
25: // pnuts/multithread/thread
26: { "getPriority", "setPriority", "sleep", "mutex" },
27: { "threadGroup" } };
28:
29: static String[] javaFunctions = { "async", "currentThread", "sync",
30: "threadLocal", "fork", "createThread" };
31:
32: static String[] requiredModules = { "pnuts.lib" };
33:
34: protected String[] getRequiredModules() {
35: return requiredModules;
36: }
37:
38: protected String getPrefix() {
39: return "org";
40: }
41:
42: public Object execute(Context context) {
43: for (int i = 0; i < files.length; i++) {
44: autoload(functions[i], files[i], context);
45: }
46: for (int i = 0; i < javaFunctions.length; i++) {
47: autoloadFunction(javaFunctions[i], context);
48: }
49: Package pkg = getPackage(context);
50: String THREADPOOL = "threadPool".intern();
51: pkg.set(THREADPOOL, new _threadPool(), context);
52: pkg.export(THREADPOOL);
53: return null;
54: }
55: }
|