public void OneProdOneClear() { BoundedQueue <int> queue = new BoundedQueue <int>(2); ParallelTasks ptasks = new ParallelTasks(); // PRODUCER thread inserts 4 elements ptasks.Add("Producer", () => { for (int i = 0; i < 4; i++) { queue.Enqueue(i); } }); // CLEAR thread clears queue once it reaches size 2 ptasks.Add("Clear", () => { while (queue.Size() < 2) { Thread.Sleep(0); } queue.Clear(); }); ptasks.Execute(); }
public void Reset() { Log.Info("Generating map..."); Cave = MapGenerator.GenerateRandomCave(); Wumpus = new Wumpus(this); Player = new Player(); PlayerRoomLocation = new Point(0, 0); MoveCount = 0; Room FirstSafeRoom = GetPlayerStartRoom(); if (FirstSafeRoom != null) { PlayerRoom = FirstSafeRoom.RoomID; } else { Log.Error("Couldn't find valid room to move player to!"); } Wumpus.SetInitialPosition(); CollectItemsFromRoom(); PlayerPath.Clear(); PlayerPath.Enqueue(PlayerRoom); }
public void Clear() { history.Clear(); Root.Inlines.Clear(); }