Inheritance: IDisposable
Beispiel #1
0
		public void Test1Test()
		{
			var Values = new List<int>();

			var Thread1 = new GreenThread();
			var Thread2 = new GreenThread();
			Thread1.InitAndStartStopped(() =>
			{
				Values.Add(1);
				GreenThread.Yield();
				Values.Add(3);
			});
			Thread2.InitAndStartStopped(() =>
			{
				Values.Add(2);
				GreenThread.Yield();
				Values.Add(4);
			});

			Thread.Sleep(20);
			// Inits stopped.
			Assert.AreEqual("[]", Values.ToJson());
			Thread1.SwitchTo();
			Assert.AreEqual("[1]", Values.ToJson());
			Thread2.SwitchTo();
			Assert.AreEqual("[1,2]", Values.ToJson());
			Thread.Sleep(20);
			Thread1.SwitchTo();
			Assert.AreEqual("[1,2,3]", Values.ToJson());
			Thread2.SwitchTo();
			Assert.AreEqual("[1,2,3,4]", Values.ToJson());
		}
Beispiel #2
0
		static void Test1(string[] args)
		{
			//new MyFastcgiServerAsync().Listen(8000);

			var Values = new List<int>();

			var Thread1 = new GreenThread();
			var Thread2 = new GreenThread();
			Thread1.InitAndStartStopped(() =>
			{
				Values.Add(1);
				Console.WriteLine(1);
				GreenThread.Yield();
				Console.WriteLine(3);
			});
			Thread2.InitAndStartStopped(() =>
			{
				Values.Add(2);
				Console.WriteLine(2);
				GreenThread.Yield();
				Console.WriteLine(4);
			});

			Console.WriteLine("a");
			Thread1.SwitchTo();
			Thread2.SwitchTo();
			Thread1.SwitchTo();
			Thread2.SwitchTo();
			Console.WriteLine("b");
			Console.ReadKey();
		}
Beispiel #3
0
        public HleThread(PspEmulatorContext PspEmulatorContext, CpuThreadState CpuThreadState)
        {
            this.HleInterruptManager = PspEmulatorContext.GetInstance<HleInterruptManager>();
            this.HleThreadManager = PspEmulatorContext.GetInstance<HleThreadManager>();
            this.MethodCache = CpuThreadState.CpuProcessor.MethodCache;
            this.PspConfig = CpuThreadState.CpuProcessor.PspConfig;

            if (this.PspConfig.UseCoRoutines)
            {
                this.Coroutine = HleThreadManager.Processor.CoroutinePool.CreateCoroutine(this.Name, MainLoop);
            }
            else
            {
                this.GreenThread = new GreenThread();
                GreenThread.InitAndStartStopped(MainLoop);
            }

            this.CpuThreadState = CpuThreadState;
        }
Beispiel #4
0
 public HleThread(CpuThreadState CpuThreadState)
 {
     this.MethodCache = CpuThreadState.CpuProcessor.MethodCache;
     this.PspConfig = CpuThreadState.CpuProcessor.PspConfig;
     this.GreenThread = new GreenThread();
     this.CpuThreadState = CpuThreadState;
     this.PrepareThread();
 }
        public HleThread(InjectContext InjectContext, CpuThreadState CpuThreadState)
        {
            InjectContext.InjectDependencesTo(this);
            //this.PspConfig = CpuThreadState.CpuProcessor.CpuConfig;

            if (this.HleConfig.UseCoRoutines)
            {
                this.Coroutine = HleThreadManager.CoroutinePool.CreateCoroutine(this.Name, MainLoop);
            }
            else
            {
                this.GreenThread = new GreenThread();
                GreenThread.InitAndStartStopped(MainLoop);
            }

            this.CpuThreadState = CpuThreadState;
        }