private static RandomizedContext Create(ThreadGroup tg, Type suiteClass, RandomizedRunner runner) { lock (globalLock) { var context = new RandomizedContext(tg, suiteClass, runner); contexts.Add(tg, context); context.threadResources.Add(ThreadClass.Current(), new ThreadResources()); return(context); } }
private static RandomizedContext Context(ThreadClass thread) { var group = thread.Instance.GetThreadGroup(); RandomizedContext context; lock (globalLock) { while (true) { context = contexts[group]; if (context == null && group.Parent != null) { group = group.Parent; } else { break; } } // TODO: revisit if (context == null) { context = contexts[group] = new RandomizedContext(group, null, null); } } if (context == null) { // TODO: revisit var message = "No context information for thread," + thread.Name + ". " + "Is this thread running under a " + typeof(RandomizedRunner).Name + " context? "; throw new InvalidOperationException(message); } lock (context.contextLock) { if (!context.threadResources.ContainsKey(thread)) { var resources = new ThreadResources(); //resources.Queue.Enqueue(context.runner.Randomness.Clone(thread)); context.threadResources.Add(thread, resources); } } return(context); }
private static RandomizedContext Create(ThreadGroup tg, Type suiteClass, RandomizedRunner runner) { lock (globalLock) { var context = new RandomizedContext(tg, suiteClass, runner); contexts.Add(tg, context); context.threadResources.Add(ThreadClass.Current(), new ThreadResources()); return context; } }
private static RandomizedContext Context(ThreadClass thread) { var group = thread.Instance.GetThreadGroup(); RandomizedContext context; lock (globalLock) { while (true) { context = contexts[group]; if (context == null && group.Parent != null) group = group.Parent; else break; } // TODO: revisit if (context == null) { context = contexts[group] = new RandomizedContext(group, null, null); } } if (context == null) { // TODO: revisit var message = "No context information for thread," + thread.Name + ". " + "Is this thread running under a " + typeof(RandomizedRunner).Name + " context? "; throw new IllegalStateException(message); } lock (context.contextLock) { if (!context.threadResources.ContainsKey(thread)) { var resources = new ThreadResources(); //resources.Queue.Enqueue(context.runner.Randomness.Clone(thread)); context.threadResources.Add(thread, resources); } } return context; }