diff options
author | Adam Frisby | 2009-04-24 05:33:23 +0000 |
---|---|---|
committer | Adam Frisby | 2009-04-24 05:33:23 +0000 |
commit | 883f7dde3884bca10f324f6a31e0882cf23c04d8 (patch) | |
tree | 53cdc16d97034bc125c148086c689badcc7f2906 /OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/Microthreads | |
parent | Update svn properties. (diff) | |
download | opensim-SC-883f7dde3884bca10f324f6a31e0882cf23c04d8.zip opensim-SC-883f7dde3884bca10f324f6a31e0882cf23c04d8.tar.gz opensim-SC-883f7dde3884bca10f324f6a31e0882cf23c04d8.tar.bz2 opensim-SC-883f7dde3884bca10f324f6a31e0882cf23c04d8.tar.xz |
* Implements Microthreading for MRM scripting.
* This is achieved through two new keywords "microthreaded" and "relax". example:
public microthreaded void MyFunc(...) {
...
relax;
...
}
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/Microthreads')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/Microthreads/MicrothreadSample.txt | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/Microthreads/MicrothreadSample.txt b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/Microthreads/MicrothreadSample.txt new file mode 100644 index 0000000..dc15c47 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/Microthreads/MicrothreadSample.txt | |||
@@ -0,0 +1,40 @@ | |||
1 | //MRM:C# | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using OpenSim.Region.OptionalModules.Scripting.Minimodule; | ||
5 | |||
6 | namespace OpenSim | ||
7 | { | ||
8 | class MiniModule : MRMBase | ||
9 | { | ||
10 | public microthreaded void MicroThreadFunction(string testparam) | ||
11 | { | ||
12 | Host.Object.Say("Hello " + testparam); | ||
13 | |||
14 | relax; // the 'relax' keyword gives up processing time. | ||
15 | // and should be inserted before, after or in | ||
16 | // any computationally "heavy" zones. | ||
17 | |||
18 | int c = 500; | ||
19 | while(c-- < 0) { | ||
20 | Host.Object.Say("C=" + c); | ||
21 | relax; // Putting 'relax' in microthreaded loops | ||
22 | // is an easy way to lower the CPU tax | ||
23 | // on your script. | ||
24 | } | ||
25 | |||
26 | } | ||
27 | |||
28 | public override void Start() | ||
29 | { | ||
30 | Host.Microthreads.Run( | ||
31 | MicroThreadFunction("World!") | ||
32 | ); | ||
33 | } | ||
34 | |||
35 | public override void Stop() | ||
36 | { | ||
37 | |||
38 | } | ||
39 | } | ||
40 | } | ||