aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs
diff options
context:
space:
mode:
authorAdam Frisby2009-04-24 05:33:23 +0000
committerAdam Frisby2009-04-24 05:33:23 +0000
commit883f7dde3884bca10f324f6a31e0882cf23c04d8 (patch)
tree53cdc16d97034bc125c148086c689badcc7f2906 /OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs
parentUpdate svn properties. (diff)
downloadopensim-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/TestModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs
index 702ac74..73af7f0 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs
@@ -25,12 +25,55 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Collections;
29using System.Collections.Generic;
28using OpenSim.Region.OptionalModules.Scripting.Minimodule; 30using OpenSim.Region.OptionalModules.Scripting.Minimodule;
29 31
30namespace OpenSim 32namespace OpenSim
31{ 33{
32 class MiniModule : MRMBase 34 class MiniModule : MRMBase
33 { 35 {
36 // private microthreaded Function(params...)
37 private IEnumerable TestMicrothread(string param)
38 {
39 Host.Console.Info("Microthreaded " + param);
40 // relax;
41 yield return null;
42 Host.Console.Info("Microthreaded 2" + param);
43 yield return null;
44 int c = 100;
45 while(c-- < 0)
46 {
47 Host.Console.Info("Microthreaded Looped " + c + " " + param);
48 yield return null;
49 }
50 }
51
52 public void Microthread(IEnumerable thread)
53 {
54
55 }
56
57 public void RunMicrothread()
58 {
59 List<IEnumerator> threads = new List<IEnumerator>();
60 threads.Add(TestMicrothread("A").GetEnumerator());
61 threads.Add(TestMicrothread("B").GetEnumerator());
62 threads.Add(TestMicrothread("C").GetEnumerator());
63
64 Microthread(TestMicrothread("Ohai"));
65
66 int i = 0;
67 while(threads.Count > 0)
68 {
69 i++;
70 bool running = threads[i%threads.Count].MoveNext();
71
72 if (!running)
73 threads.Remove(threads[i%threads.Count]);
74 }
75 }
76
34 public override void Start() 77 public override void Start()
35 { 78 {
36 // Say Hello 79 // Say Hello