public static ThreadData LoadFromXml(XmlNode node) { if (null == node) return null; ThreadData tData = new ThreadData(); string strThreadId = XmlLoaderBase.getInnerTextByPath(node, "./thread/id"); if (null != strThreadId && strThreadId != "") { tData.m_nThreadId = Convert.ToInt32(strThreadId, 16); } else { return null; } tData.m_strThreadStatus = XmlLoaderBase.getInnerTextByPath(node, "./thread/status"); XmlNodeList lstNode = node.SelectNodes("./thread/stack"); if (null == lstNode) return null; tData.m_lstStackData = new List<StackData>(); foreach (XmlNode n in lstNode) { if (null == n) continue; StackData sData = StackDataLoader.LoadFromXml(n); if (null == sData) return null; tData.m_lstStackData.Add(sData); } return tData; }
public void CanConvertConcurrently() { var error = false; var threads = new List<ThreadData>(); for (int i = 0; i < 5; i++) { var tmp = new ThreadData() { Thread = new Thread(ThreadStart), WaitHandle = new ManualResetEvent(false) }; threads.Add(tmp); tmp.Thread.Start(tmp); } var handles = threads.Select(x => x.WaitHandle).ToArray(); Assert.IsTrue(WaitHandle.WaitAll(handles, ConcurrentTimeout), "At least one thread timeout"); //WaitAll(handles); threads.ForEach(x => x.Thread.Abort()); var exceptions = threads.Select(x => x.Exception).Where(x => x != null); foreach (var tmp in threads) { if (tmp.Exception != null) { error = true; var tid = tmp.Thread.ManagedThreadId; } } Assert.IsFalse(error, "At least one thread failed!"); }
private void button1_Click(object sender, EventArgs e) { var t1 = new Thread(IncrementThreadFun); var t2 = new Thread(IncrementThreadFun); var data = new ThreadData() { Val = 0 }; t1.Start(data); t2.Start(data); t1.Join(); t2.Join(); label1.Text = data.Val.ToString(); }
private static void PointScale(ThreadData threadData) { for (int y = threadData.start; y < threadData.end; y++) { var thisY = (int)(ratioY * y) * w; var yw = y * w2; for (int x = 0; x < w2; x++) { newColors[yw + x] = texColors[thisY + (int)(ratioX * x)]; } } finishCount++; }
private static void ThreadedScale(Texture2D tex, int newWidth, int newHeight, bool useBilinear) { texColors = tex.GetPixels(); newColors = new Color[newWidth * newHeight]; if (useBilinear) { ratioX = 1.0f / ((float)newWidth / (tex.width - 1)); ratioY = 1.0f / ((float)newHeight / (tex.height - 1)); } else { ratioX = ((float)tex.width) / newWidth; ratioY = ((float)tex.height) / newHeight; } w = tex.width; w2 = newWidth; var cores = Mathf.Min(SystemInfo.processorCount, newHeight); var slice = newHeight / cores; finishCount = 0; if (mutex == null) { mutex = new Mutex(false); } if (cores > 1) { int i = 0; ThreadData threadData; for (i = 0; i < cores - 1; i++) { threadData = new ThreadData(slice * i, slice * (i + 1)); ParameterizedThreadStart ts = useBilinear ? new ParameterizedThreadStart(BilinearScale) : new ParameterizedThreadStart(PointScale); Thread thread = new Thread(ts); thread.Start(threadData); } threadData = new ThreadData(slice * i, newHeight); if (useBilinear) { BilinearScale(threadData); } else { PointScale(threadData); } while (finishCount < cores) { Thread.Sleep(1); } } else { ThreadData threadData = new ThreadData(0, newHeight); if (useBilinear) { BilinearScale(threadData); } else { PointScale(threadData); } } tex.Resize(newWidth, newHeight); tex.SetPixels(newColors); tex.Apply(); }
public Scraper(ThreadData td, Action act) { var handler = new HttpClientHandler { AllowAutoRedirect = true, AutomaticDecompression = DecompressionMethods.GZip & DecompressionMethods.Deflate, UseCookies = false, UseProxy = false }; _client = new HttpClient(handler); _thread = td; _action = act; }
public bool Start(usrc_FVI_SLO_MessageBox xusrc_FVI_SLO_MessageBox,int message_box_length,bool fursTESTEnvironment, string certificateFileName, string CertPass, string fursWebServiceURL, string fursXmlNamespace, int timeOutInSec, ref string ErrReason) { try { ThreadData thdata = new ThreadData(fursTESTEnvironment,certificateFileName, CertPass, fursWebServiceURL, fursXmlNamespace, timeOutInSec, xusrc_FVI_SLO_MessageBox); message_box = new Thread_FVI_MessageBox(message_box_length); FVI_Thread = new System.Threading.Thread(Run); FVI_Thread.SetApartmentState(ApartmentState.STA); FVI_Thread.Start(thdata); return true; } catch (Exception ex) { ErrReason = ex.Message; return false; } }
public static bool RunTest(int n) { ThreadData data = new ThreadData(); data.autoEvent = new AutoResetEvent(false); data.initialAllocation = n; Thread t = new Thread(data.Run); t.Start(); if (!t.IsAlive) { return false; } data.autoEvent.Set(); t.Join(); bool ok = data.result == 100; return ok; }
public bool Start(int message_box_length, ThreadP_Message.delegate_Procedure proc, object xparam, int timeOutInSec, ref string ErrReason) { try { m_ThreadP2Ctrl_MessageBox = new ThreadP2Ctrl_MessageBox(message_box_length); ThreadData thdata = new ThreadData(proc, xparam, timeOutInSec, m_ThreadP2Ctrl_MessageBox); message_box = new ThreadP_MessageBox(message_box_length); FVI_Thread = new System.Threading.Thread(Run); FVI_Thread.SetApartmentState(ApartmentState.STA); FVI_Thread.Start(thdata); return true; } catch (Exception ex) { ErrReason = ex.Message; return false; } }
public void ClearMarkedPostsAsync(ThreadData thread, Action<Awful.Core.Models.ActionResult> result) { AsyncCallback getResponse = (callback) => { try { HttpWebRequest request = callback.AsyncState as HttpWebRequest; HttpWebResponse response = request.EndGetResponse(callback) as HttpWebResponse; Deployment.Current.Dispatcher.BeginInvoke(() => { if (response.StatusCode == HttpStatusCode.OK) result(Awful.Core.Models.ActionResult.Success); else result(Awful.Core.Models.ActionResult.Failure); }); } catch (Exception ex) { Awful.Core.Event.Logger.AddEntry(string.Format("ClearMarkedPosts: An error occured. [{0}] - {1}", ex.Message, ex.StackTrace)); Deployment.Current.Dispatcher.BeginInvoke(() => { result(Awful.Core.Models.ActionResult.Failure); }); } }; AsyncCallback getRequest = (callback) => { HttpWebRequest request = callback.AsyncState as HttpWebRequest; using (StreamWriter writer = new StreamWriter(request.EndGetRequestStream(callback))) { string postData = string.Format("json=1&action=resetseen&threadid={0}", thread.ID.ToString()); writer.Write(postData); writer.Close(); } request.BeginGetResponse(getResponse, request); }; ThreadPool.QueueUserWorkItem(state => { HttpWebRequest request = Awful.Core.Web.AwfulWebRequest.CreatePostRequest("http://forums.somethingawful.com/showthread.php"); request.BeginGetRequestStream(getRequest, request); }, null); }
public void FetchThreadPage(ThreadData thread, int pageNumber, Action<ThreadPageData> action) { // http://forums.somethingawful.com/showthread.php?noseen=0&threadid=3439182&pagenumber=69 var url = new StringBuilder(); // http://forums.somethingawful.com/showthread.php url.AppendFormat("{0}/{1}", Constants.BASE_URL, Constants.THREAD_PAGE_URI); // noseen=0&threadid=<THREADID>&pagenumber=<PAGENUMBER> url.AppendFormat("noseen=0&threadid={0}&pagenumber={1}", thread.ID, pageNumber); var web = new WebGet(); web.LoadAsync(url.ToString(), (ar, doc) => { ThreadPageData result = null; if (ar == ActionResult.Success) { result = AwfulThreadParser.ParseFromThreadPage(doc.Document); } action(result); }); }
public void WithActivationFunction_DifferentObjectsPerThreadAreReturned() { var lifecycle = new LightCore.Lifecycle.ThreadSingletonLifecycle(); var factory = this.GetActivationFactory(); var threadData = new ThreadData(lifecycle, factory); var thread = new Thread(threadData.ResolveFoosWithLifecycle); var threadDataTwo = new ThreadData(lifecycle, factory); var threadTwo = new Thread(threadDataTwo.ResolveFoosWithLifecycle); thread.Start(); threadTwo.Start(); thread.Join(); threadTwo.Join(); Assert.IsTrue(ReferenceEquals(threadData.FooOne, threadData.FooTwo)); Assert.IsFalse(ReferenceEquals(threadData.FooOne, threadDataTwo.FooOne)); }
private static void BilinearScale(ThreadData threadData) { for (int y = threadData.start; y < threadData.end; y++) { var yFloor = Mathf.Floor(y * ratioY); var y1 = yFloor * w; var y2 = (yFloor + 1) * w; var yw = y * w2; for (int x = 0; x < w2; x++) { var xFloor = Mathf.Floor(x * ratioX); var xLerp = x * ratioX - xFloor; newColors[yw + x] = ColorLerpUnclamped(ColorLerpUnclamped(texColors[(int)(y1 + xFloor)], texColors[(int)(y1 + xFloor + 1)], xLerp), ColorLerpUnclamped(texColors[(int)(y2 + xFloor)], texColors[(int)(y2 + xFloor + 1)], xLerp), y * ratioY - yFloor); } } finishCount++; }
public void CanConvertConcurrently() { var error = false; var threads = new List <ThreadData>(); for (int i = 0; i < 8; i++) { var tmp = new ThreadData() { Thread = new Thread(ThreadStart), WaitHandle = new ManualResetEvent(false) }; threads.Add(tmp); tmp.Thread.Start(tmp); } var handles = threads.Select(x => x.WaitHandle).ToArray(); Assert.IsTrue(WaitHandle.WaitAll(handles, ConcurrentTimeout), "At least one thread timeout"); //WaitAll(handles); threads.ForEach(x => x.Thread.Abort()); var exceptions = threads.Select(x => x.Exception).Where(x => x != null); foreach (var tmp in threads) { if (tmp.Exception != null) { error = true; var tid = tmp.Thread.ManagedThreadId; _Log.Error("Thread-" + tid + " failed!", tmp.Exception); } } Assert.IsFalse(error, "At least one thread failed!"); }
public ThreadTimelineItem(ProcessData process, ThreadData thread) : base(thread.ThreadID.ToString(), thread) { Color = Colors.SkyBlue; Children = new List <Timeline.IItem>(); List <FunctionTimelineItem> toAdd = new List <FunctionTimelineItem>(); foreach (SysCallData call in thread.SysCalls) { SymbolInfo symbol = new SymbolInfo(); ProcessUtils.Symbols.Resolve(call.Address, out symbol); toAdd.Add(new FunctionTimelineItem(symbol.Symbol, call)); } foreach (IOData data in thread.IORequests) { toAdd.Add(new FunctionTimelineItem(data.FileName, data)); } //GenerateSampledTree(process, thread); toAdd.Sort((a, b) => a.Start.CompareTo(b.Start)); toAdd.ForEach(child => AddChild(child)); for (int i = 0; i < thread.WorkIntervals.Count - 1; ++i) { EventData ev = new EventData() { Start = thread.WorkIntervals[i].Finish, Finish = thread.WorkIntervals[i + 1].Start }; if (ev.IsValid) { Children.Add(new WaitTimelineItem(ev)); } } }
public async Task <ActionResult <bool> > UnsubscribeThreadAsync([FromBody] ThreadData data) { var uid = User.GetNumericId(); if (uid is null) { return(Unauthorized()); } var threadSubscriber = await _context.CommentsThreadSubscribers .Where(cts => cts.OgmaUserId == uid) .Where(cts => cts.CommentsThreadId == data.ThreadId) .FirstOrDefaultAsync(); if (threadSubscriber is null) { return(true); } _context.CommentsThreadSubscribers.Remove(threadSubscriber); await _context.SaveChangesAsync(); return(false); }
public static void BilinearScale(System.Object obj) { ThreadData threadData = (ThreadData)obj; for (var y = threadData.start; y < threadData.end; y++) { int yFloor = (int)Mathf.Floor(y * ratioY); var y1 = yFloor * w; var y2 = (yFloor + 1) * w; var yw = y * w2; for (var x = 0; x < w2; x++) { int xFloor = (int)Mathf.Floor(x * ratioX); var xLerp = x * ratioX - xFloor; newColors[yw + x] = ColorLerpUnclamped(ColorLerpUnclamped(texColors[y1 + xFloor], texColors[y1 + xFloor + 1], xLerp), ColorLerpUnclamped(texColors[y2 + xFloor], texColors[y2 + xFloor + 1], xLerp), y * ratioY - yFloor); } } mutex.WaitOne(); finishCount++; mutex.ReleaseMutex(); }
public static void CreateNewThread(uint entry) { ThreadData data = new ThreadData(); uint userStack = (uint)GCImplementation.AllocNewObject(4096); uint * stack = (uint *)(userStack + 4096); *--stack = 0x10; // ss ? *--stack = 0x00000202; // eflags *--stack = 0x8; // cs *--stack = entry; // eip *--stack = 0; // error *--stack = 0; // int *--stack = 0; // eax *--stack = 0; // ecx *--stack = 0; // edx *--stack = 0; // ebx *--stack = 0; // offset *--stack = userStack + 4096; //ebp *--stack = 0; // esi *--stack = 0; // edi data.ESP = (uint)stack; allThreads.Add(data); }
static void DataLoadingThread(Object threadArgs) { ThreadData data = (ThreadData)threadArgs; Dictionary <ChannelInfo, DataTable> tables = new Dictionary <ChannelInfo, DataTable>(); foreach (ChannelInfo info in data.query.Channels) { List <ChannelInfo> tmp = new List <ChannelInfo>(); tmp.Add(info); DataTable dt = ArchiverMain.Current.GetChannelData(data.query.From, data.query.To, tmp); if (dt != null) { tables[info] = dt; } } if (tables.Count > 0) { object[] args = new object[1]; args[0] = tables; data.view.BeginInvoke(new LoadingFinishedDelegate(data.view.OnLoadingFinished), args); } }
private void ExecutePoolWork(ThreadData selfData) { try { while (_ct.IsCancellationRequested == false) // cancellation token { selfData.StopWork.Wait(_ct); _selfInformation = selfData; ExecuteWorkOnce(); _selfInformation = null; _freedThreadsValue.Value = true; } } catch (OperationCanceledException) { //expected } catch (Exception e) { logger.FatalException("Error while running background tasks, this is very bad", e); } }
public void ProcessMesh(object obj) { ThreadData data = (ThreadData)obj; GDMesh.Element custom = data.custom as GDMesh.Element; GDMesh mesh = data._gdmesh as GDMesh; int[] numArray = data.custom2 as int[]; int num = (int)data.custom3; int num2 = (int)data.custom4; int start = data.start; int end = data.end; try { for (int i = start; i < end; i += 3) { if ((i + 2) < numArray.Length) { FaceTrait vt = new FaceTrait(num2 + (i / 3)); vt.ID = num2 + (i / 3); vt.subMeshIndex = num; vt.subMeshTriID = i; mesh.AddTriangle(vt, this.vertices[numArray[i]], this.vertices[numArray[i + 1]], this.vertices[numArray[i + 2]]).Element = custom; } } this.mutex.WaitOne(); this.finishedCount++; this.mutex.ReleaseMutex(); } catch (Exception exception) { this.ex = exception; this.finishedCount = -1; } }
public void Instance_is_reused_on_same_thread_when_controlled_by_threadsingleton_lifecycle() { var builder = new ContainerBuilder(); builder.DefaultControlledBy <ThreadSingletonLifecycle>(); builder.Register <IFoo, Foo>(); builder.Register <IBar, Bar>(); var container = builder.Build(); var threadData = new ThreadData(container); var thread = new Thread(threadData.ResolveFoosWithContainer); var threadDataTwo = new ThreadData(container); var threadTwo = new Thread(threadDataTwo.ResolveFoosWithContainer); thread.Start(); threadTwo.Start(); thread.Join(); threadTwo.Join(); threadData.FooOne.Should().BeSameAs(threadData.FooTwo); }
private unsafe void DoViterbi(char *sentence, int len, ThreadData work) { work.BosNode = this.tokenizer.GetBosNode(); work.BosNode.Length = len; char *begin = sentence; char *end = begin + len; work.BosNode.Surface = new string(begin, 0, len); work.EndNodeList[0] = work.BosNode; for (int pos = 0; pos < len; pos++) { if (work.EndNodeList[pos] != null) { MeCabNode rNode = tokenizer.Lookup(begin + pos, end); rNode = this.FilterNode(rNode, pos, work); rNode.BPos = pos; rNode.EPos = pos + rNode.RLength; work.BeginNodeList[pos] = rNode; this.connect(pos, rNode, work); } } work.EosNode = tokenizer.GetEosNode(); work.EosNode.Surface = end->ToString(); work.BeginNodeList[len] = work.EosNode; for (int pos = len; pos >= 0; pos--) { if (work.EndNodeList[pos] != null) { this.connect(pos, work.EosNode, work); break; } } }
public void ToggleBookmarkAsync(ThreadData thread, BookmarkAction action, Action<Awful.Core.Models.ActionResult> result) { Awful.Core.Event.Logger.AddEntry(string.Format("ToggleBookmarkAsync - ThreadID: {0}, Action: {1}", thread.ID, action)); string url = String.Format("{0}/{1}", Globals.Constants.SA_BASE, Globals.Constants.BOOKMARK_THREAD); Awful.Core.Event.Logger.AddEntry(string.Format("ToggleBookmarkAsync - Bookmark url: {0}", url)); AutoResetEvent bookmarkSignal = new AutoResetEvent(false); bool bookmarkSuccess = false; Action<IAsyncResult> ProccessBookmarkGetRequestStream = null; Action<IAsyncResult> ProccessBookmarkBeginGetResponse = null; ProccessBookmarkGetRequestStream = (asyncResult) => { try { Awful.Core.Event.Logger.AddEntry("ToggleBookmarkAsync - Initializingweb request..."); HttpWebRequest request = asyncResult.AsyncState as HttpWebRequest; StreamWriter writer = new StreamWriter(request.EndGetRequestStream(asyncResult)); var postData = String.Format("{0}&{1}={2}", action == BookmarkAction.Add ? Globals.Constants.ADD_BOOKMARK : Globals.Constants.REMOVE_BOOKMARK, Globals.Constants.THREAD_ID, thread.ID); Awful.Core.Event.Logger.AddEntry(string.Format("ToggleBookmarkAsync - PostData: {0}", postData)); writer.Write(postData); writer.Close(); bookmarkSuccess = true; Awful.Core.Event.Logger.AddEntry("ToggleBookmarkAsync - Web request initialization successful."); } catch (Exception) { Awful.Core.Event.Logger.AddEntry("ToggleBookmarkAsync - Web request initialization failed."); bookmarkSuccess = false; } bookmarkSignal.Set(); }; ProccessBookmarkBeginGetResponse = (asyncResult) => { Awful.Core.Event.Logger.AddEntry("ToggleBookmarkAsync - Start Get Response..."); HttpWebRequest request = asyncResult.AsyncState as HttpWebRequest; HttpWebResponse response = request.EndGetResponse(asyncResult) as HttpWebResponse; if (response.StatusCode == HttpStatusCode.OK) { Awful.Core.Event.Logger.AddEntry("ToggleBookmarkAsync - Start Get Response successful."); Awful.Core.Event.Logger.AddEntry(string.Format("ToggleBookmarkAsync - Repsonse url: {0}", response.ResponseUri)); bookmarkSuccess = true; } else { Awful.Core.Event.Logger.AddEntry("ToggleBookmarkAsync - Start Get Response failed."); bookmarkSuccess = false; } bookmarkSignal.Set(); }; ThreadPool.QueueUserWorkItem(new WaitCallback((state) => { var request = state as HttpWebRequest; var callback = new AsyncCallback(ProccessBookmarkGetRequestStream); var dispatch = Deployment.Current.Dispatcher; request.BeginGetRequestStream(callback, request); bookmarkSignal.WaitOne(); if (!bookmarkSuccess) { dispatch.BeginInvoke(() => { result(Awful.Core.Models.ActionResult.Failure); }); return; } callback = new AsyncCallback(ProccessBookmarkBeginGetResponse); request.BeginGetResponse(callback, request); bookmarkSignal.WaitOne(); if (!bookmarkSuccess) { dispatch.BeginInvoke(() => { result(Awful.Core.Models.ActionResult.Failure); }); return; } dispatch.BeginInvoke(() => { result(Awful.Core.Models.ActionResult.Success); }); return; }), InitializePostRequest(url)); }
private void Work() { string threadParam = null; int localCallsCounter = 0, localRepeatCounter = 0; var interrupted = false; while (!_disposed) { if (!interrupted) { try { Thread.Sleep(Timeout.Infinite); } catch (ThreadInterruptedException) { if (_disposed) { return; } } threadParam = _param; localCallsCounter = 0; localRepeatCounter = 0; } interrupted = false; try { var dataSlot = Thread.GetNamedDataSlot(threadParam); var dataSlotValue = Thread.GetData(dataSlot) as ThreadData; if (dataSlotValue == null) { var value = threadParam.Sum(x => x); var random = new Random(Thread.CurrentThread.ManagedThreadId); int randomValue; var values = new List <int>(); do { localCallsCounter++; randomValue = random.Next(-100000, 100000); if (values.Contains(randomValue)) { localRepeatCounter++; } else { values.Add(randomValue); } } while (randomValue != value); dataSlotValue = new ThreadData(threadParam, localRepeatCounter, localCallsCounter); Thread.SetData(dataSlot, dataSlotValue); } callsCounter += localCallsCounter; repeatCounter += localCallsCounter; Console.WriteLine($"Thread {Thread.CurrentThread.ManagedThreadId}: {dataSlotValue.Param} - {dataSlotValue.Calls}/{callsCounter} calls with {dataSlotValue.Repeats}/{repeatCounter} repeats"); } catch (ThreadInterruptedException) { interrupted = true; continue; } } }
void InitThreadList(FrameGroup group) { rows.Clear(); id2row.Clear(); ThreadList.RowDefinitions.Clear(); ThreadList.Children.Clear(); if (group == null) { return; } rows.Add(new HeaderThreadRow(group) { GradientTop = (BroAlternativeBackground as SolidColorBrush).Color, GradientBottom = (BroBackground as SolidColorBrush).Color, SplitLines = (BroBackground as SolidColorBrush).Color, TextColor = Colors.Gray }); for (int i = 0; i < Math.Min(group.Board.Threads.Count, group.Threads.Count); ++i) { ThreadDescription thread = group.Board.Threads[i]; ThreadData data = group.Threads[i]; bool threadHasData = false; if ((data.Callstacks != null && data.Callstacks.Count > 3) || /*(data.Sync != null && data.Sync.Intervals.Count > 0) || */ (data.Events != null && data.Events.Count > 0)) { threadHasData = true; } if (threadHasData) { EventsThreadRow row = new EventsThreadRow(group, thread, data); rows.Add(row); id2row.Add(i, row); row.EventNodeHover += Row_EventNodeHover; row.EventNodeSelected += Row_EventNodeSelected; } } scroll.TimeSlice = group.Board.TimeSlice; scroll.Height = 0.0; scroll.Width = surface.ActualWidth * RenderSettings.dpiScaleX; rows.ForEach(row => scroll.Height += row.Height); rows.ForEach(row => row.BuildMesh(surface, scroll)); ThreadList.Margin = new Thickness(0, 0, 3, 0); double offset = 0.0; for (int threadIndex = 0; threadIndex < rows.Count; ++threadIndex) { ThreadRow row = rows[threadIndex]; row.Offset = offset; ThreadList.RowDefinitions.Add(new RowDefinition()); Thickness margin = new Thickness(0, 0, 0, 0); Label labelName = new Label() { Content = row.Name, Margin = margin, Padding = new Thickness(), FontWeight = FontWeights.Bold, Height = row.Height / RenderSettings.dpiScaleY, VerticalContentAlignment = VerticalAlignment.Center }; Grid.SetRow(labelName, threadIndex); if (threadIndex % 2 == 1) { labelName.Background = BroAlternativeBackground; } ThreadList.Children.Add(labelName); offset += row.Height; } InitBackgroundMesh(); }
public virtual void ReloadCurrentPageAsync(ThreadData thread, int postNumber = -1) { this.IsPageLoading = true; this.ThreadTitle = thread.ThreadTitle; this.Posts = null; this._TotalPages = thread.MaxPages; this._reload = true; SAThread saThread = thread as SAThread; SAThreadPage tPage = new SAThreadPage(saThread, this._CurrentPage, this.CurrentUserID); this._Cancellable = SAThreadPageFactory.BuildAsync((result, page) => { postNumber = thread.LastViewedPostIndex; thread.LastViewedPageIndex = 0; thread.LastViewedPostIndex = -1; ThreadPool.QueueUserWorkItem(state => { this.HandleResult(result, page, postNumber); }, null); }, tPage); }
public TimeStepData Copy(TimeStepData _timeStep) { TimeStepData timeStep = new TimeStepData(); for (int i = 0; i < _timeStep.threads.Count; i++) { ThreadData thread = new ThreadData(); thread.id = _timeStep.threads[i].id; thread.pos = new Vector2(_timeStep.threads[i].pos.x, _timeStep.threads[i].pos.y); thread.rotation = new Vector3(_timeStep.threads[i].rotation.x, _timeStep.threads[i].rotation.y, _timeStep.threads[i].rotation.z); thread.packages = new List <PackageData>(); for (int j = 0; j < _timeStep.threads[i].packages.Count; j++) { PackageData package = new PackageData(); package.id = _timeStep.threads[i].packages[j].id; package.active = _timeStep.threads[i].packages[j].active; thread.packages.Add(package); } timeStep.threads.Add(thread); } for (int i = 0; i < _timeStep.pickups.Count; i++) { PickupData pickup = new PickupData(); pickup.id = _timeStep.pickups[i].id; pickup.available = _timeStep.pickups[i].available; timeStep.pickups.Add(pickup); } for (int i = 0; i < _timeStep.deliveryPoints.Count; i++) { DeliveryData delivery = new DeliveryData(); delivery.id = _timeStep.deliveryPoints[i].id; delivery.deliveries = _timeStep.deliveryPoints[i].deliveries; timeStep.deliveryPoints.Add(delivery); } for (int i = 0; i < _timeStep.sempahores.Count; i++) { SemaphoreData semaphore = new SemaphoreData(); semaphore.id = _timeStep.sempahores[i].id; semaphore.open = _timeStep.sempahores[i].open; timeStep.sempahores.Add(semaphore); } for (int i = 0; i < _timeStep.conditionals.Count; i++) { ConditionalData conditional = new ConditionalData(); conditional.id = _timeStep.conditionals[i].id; conditional.current = _timeStep.conditionals[i].current; conditional.directions = new string[_timeStep.conditionals[i].directions.Length]; for (int j = 0; j < _timeStep.conditionals[i].directions.Length; j++) { conditional.directions[j] = _timeStep.conditionals[i].directions[j]; } timeStep.conditionals.Add(conditional); } for (int i = 0; i < _timeStep.signals.Count; i++) { SignalData signal = new SignalData(); signal.id = _timeStep.signals[i].id; signal.passed = _timeStep.signals[i].passed; timeStep.signals.Add(signal); } return(timeStep); }
public ThreadTimelineItem(ThreadData thread) { Thread = thread; }
public void RemoveThreadFromBookmarksAsync(ThreadData thread, Action<ActionResult> action) { throw new NotImplementedException(); }
public void MarkThreadAsUnread(ThreadData thread) { throw new NotImplementedException(); }
public bool IsOriginalPosterOfThread(ThreadData thread) { return thread.Author == this.Username; }
public void AddThreadToBookmarksAsync(ThreadData thread, Action<ActionResult> action) { throw new NotImplementedException(); }
public void AddBookmarkAsync(ThreadData data, Action<Awful.Core.Models.ActionResult> result) { bookmarkSvc.ToggleBookmarkAsync(data, BookmarkAction.Add, result); }
IEnumerator ParseSteps() { playerInteraction.playerInteraction_UI.loadingText.text = "Parsing..."; currentStep = 0; paused = false; Level lvl = GameManager.Instance.GetDataManager().currentLevelData; if(lvl.execution.Count > 0) { int maxStep = 0; stepDictionary = new Dictionary<int, List<StepData>>(); Dictionary<int, List<int>> componentStepsDictionary = new Dictionary<int, List<int>>(); timeSteps = new List<TimeStepData>(); List<GridComponent> threads = new List<GridComponent>(); foreach (GridComponent g in lvl.components) { if (g.type == "thread") { threads.Add(g); } } yield return new WaitForSeconds(1f); System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); for (int i = 0; i < lvl.execution.Count; i++) { StepData step = lvl.execution[i]; if (step.timeStep > maxStep) { maxStep = step.timeStep; } if (step.eventType == "M") { if (!componentStepsDictionary.ContainsKey(step.componentID)) { componentStepsDictionary.Add(step.componentID, new List<int>()); componentStepsDictionary[step.componentID].Add(i); } else { componentStepsDictionary[step.componentID].Add(i); } } if (stepDictionary.ContainsKey(step.timeStep)) { if (step.eventType == "D") { stepDictionary[step.timeStep].Insert(0, step); } else { stepDictionary[step.timeStep].Add(step); } } else { stepDictionary[step.timeStep] = new List<StepData>(); stepDictionary[step.timeStep].Add(step); } if(stopwatch.ElapsedMilliseconds > 1000 / 60) { stopwatch.Stop(); stopwatch.Reset(); yield return new WaitForEndOfFrame(); stopwatch.Start(); } } //create in between steps for thread movements for (int i = 0; i <= maxStep; i++) { if (stepDictionary.ContainsKey(i) == false) stepDictionary.Add(i, new List<StepData>()); if (stepDictionary[i] == null) stepDictionary[i] = new List<StepData>(); if (stepDictionary[i].Count == 0) { for (int j = 0; j < threads.Count; j++) { Vector2 prevPos = new Vector2(); if (i > 0) { for (int k = 0; k < stepDictionary[i - 1].Count; k++) { if (stepDictionary[i - 1][k].eventType == "M" && stepDictionary[i - 1][k].componentID == threads[j].id) { prevPos = stepDictionary[i - 1][k].componentPos; } } } Vector2 nextPos = prevPos; bool end = false; for (int k = i + 1; k < maxStep+1; k++) { if (stepDictionary.ContainsKey(k)) { for (int l = 0; l < stepDictionary[k].Count; l++) { if (stepDictionary[k][l].eventType == "M" && stepDictionary[k][l].componentID == threads[j].id) { if (stepDictionary[k][l].componentPos != prevPos) { if (Vector2.Distance(prevPos, stepDictionary[k][l].componentPos) > 1 || Vector2.Distance(prevPos, stepDictionary[k][l].componentPos) < -1) { if (k - Mathf.Abs(Vector2.Distance(prevPos, stepDictionary[k][l].componentPos)) == i - 1) { if (prevPos.x != stepDictionary[k][l].componentPos.x) { if (prevPos.x > stepDictionary[k][l].componentPos.x) { nextPos = new Vector2(nextPos.x - 1, nextPos.y); } else { nextPos = new Vector2(nextPos.x + 1, nextPos.y); } } else { if (prevPos.y > stepDictionary[k][l].componentPos.y) { nextPos = new Vector2(nextPos.x, nextPos.y - 1); } else { nextPos = new Vector2(nextPos.x, nextPos.y + 1); } } } } } end = true; break; } } if (end == true) { break; } } } StepData newStep = new StepData(); newStep.componentID = threads[j].id; newStep.componentPos = nextPos; newStep.eventType = "M"; newStep.timeStep = i; stepDictionary[i].Add(newStep); } } else { List<bool> hasTimeStepData = new List<bool>(); for (int j = 0; j < threads.Count; j++) { hasTimeStepData.Add(false); } for (int j = 0; j < stepDictionary[i].Count; j++) { if (stepDictionary[i][j].eventType == "M") { for (int k = 0; k < threads.Count; k++) { if (threads[k].id == stepDictionary[i][j].componentID) { hasTimeStepData[k] = true; } } } } for (int j = 0; j < hasTimeStepData.Count; j++) { if (hasTimeStepData[j] == false) { Vector2 prevPos = new Vector2(); for (int k = 0; k < stepDictionary[i - 1].Count; k++) { if (stepDictionary[i - 1][k].eventType == "M" && stepDictionary[i - 1][k].componentID == threads[j].id) { prevPos = stepDictionary[i - 1][k].componentPos; } } Vector2 nextPos = prevPos; bool end = false; for (int k = i + 1; k < maxStep+1; k++) { if (stepDictionary.ContainsKey(k)) { for (int l = 0; l < stepDictionary[k].Count; l++) { if (stepDictionary[k][l].eventType == "M" && stepDictionary[k][l].componentID == threads[j].id) { if (stepDictionary[k][l].componentPos != prevPos) { if (Vector2.Distance(prevPos, stepDictionary[k][l].componentPos) > 1 || Vector2.Distance(prevPos, stepDictionary[k][l].componentPos) < -1) { if (k - Mathf.Abs(Vector2.Distance(prevPos, stepDictionary[k][l].componentPos)) == i - 1) { if (prevPos.x != stepDictionary[k][l].componentPos.x) { if (prevPos.x > stepDictionary[k][l].componentPos.x) { nextPos = new Vector2(nextPos.x - 1, nextPos.y); } else { nextPos = new Vector2(nextPos.x + 1, nextPos.y); } } else { if (prevPos.y > stepDictionary[k][l].componentPos.y) { nextPos = new Vector2(nextPos.x, nextPos.y - 1); } else { nextPos = new Vector2(nextPos.x, nextPos.y + 1); } } } } } end = true; break; } } if (end == true) { break; } } } StepData newStep = new StepData(); newStep.componentID = threads[j].id; newStep.componentPos = nextPos; newStep.eventType = "M"; newStep.timeStep = i; stepDictionary[i].Add(newStep); } } } if (stopwatch.ElapsedMilliseconds > 1000 / 60) { stopwatch.Stop(); stopwatch.Reset(); yield return new WaitForEndOfFrame(); stopwatch.Start(); } } yield return new WaitForSeconds(1f); TimeStepData timeStep = new TimeStepData(); for (int i = 0; i < lvl.components.Count; i++) { switch (lvl.components[i].type) { case "thread": ThreadData thread = new ThreadData(); thread.id = lvl.components[i].id; thread.pos = Vector2.zero; switch (lvl.components[i].configuration.initial_direction) { case "North": thread.rotation = new Vector3(0, 0, 90); break; case "South": thread.rotation = new Vector3(0, 0, -90); break; case "East": thread.rotation = new Vector3(0, 0, 0); break; case "West": thread.rotation = new Vector3(0, 0, 180); break; } timeStep.threads.Add(thread); break; case "pickup": PickupData pickup = new PickupData(); pickup.id = lvl.components[i].id; pickup.available = lvl.components[i].configuration.value; timeStep.pickups.Add(pickup); break; case "delivery": DeliveryData delivery = new DeliveryData(); delivery.id = lvl.components[i].id; delivery.deliveries = 0; timeStep.deliveryPoints.Add(delivery); break; case "semaphore": SemaphoreData semaphore = new SemaphoreData(); semaphore.id = lvl.components[i].id; semaphore.open = lvl.components[i].configuration.value; timeStep.sempahores.Add(semaphore); break; case "conditional": ConditionalData conditional = new ConditionalData(); conditional.id = lvl.components[i].id; conditional.current = lvl.components[i].configuration.current; conditional.directions = lvl.components[i].configuration.directions; timeStep.conditionals.Add(conditional); break; } if (stopwatch.ElapsedMilliseconds > 1000 / 60) { stopwatch.Stop(); stopwatch.Reset(); yield return new WaitForEndOfFrame(); stopwatch.Start(); } } yield return new WaitForSeconds(1f); for (int i = 0; i < stepDictionary.Count; i++) { if (i != 0) { timeStep = timeStep.Copy(timeSteps[i - 1]); timeStep.timeStep = i; timeStep.previousStep = timeSteps[i - 1]; timeSteps[i - 1].nextStep = timeStep; } for (int j = 0; j < stepDictionary[i].Count; j++) { switch (stepDictionary[i][j].eventType) { case "M": timeStep.GetThread(stepDictionary[i][j].componentID).pos = stepDictionary[i][j].componentPos; if (i != 0) { Vector2 difference = timeSteps[timeSteps.Count - 1].GetThread(stepDictionary[i][j].componentID).pos - timeStep.GetThread(stepDictionary[i][j].componentID).pos; if (difference.x > 0) { timeStep.GetThread(stepDictionary[i][j].componentID).rotation = new Vector3(0, 0, 180); } else if (difference.x < 0) { timeStep.GetThread(stepDictionary[i][j].componentID).rotation = new Vector3(0, 0, 0); } else if (difference.y > 0) { timeStep.GetThread(stepDictionary[i][j].componentID).rotation = new Vector3(0, 0, 90); } else if (difference.y < 0) { timeStep.GetThread(stepDictionary[i][j].componentID).rotation = new Vector3(0, 0, -90); } } break; case "D": if (stepDictionary[i][j].componentStatus.delivered_to != 0) { timeStep.GetDeliveryPoint(stepDictionary[i][j].componentStatus.delivered_to).deliveries++; } break; case "E": if (timeStep.GetSemaphore(stepDictionary[i][j].componentID) != null) { timeStep.GetSemaphore(stepDictionary[i][j].componentID).open = stepDictionary[i][j].componentStatus.value; } else if (timeStep.GetPickup(stepDictionary[i][j].componentID) != null) { timeStep.GetPickup(stepDictionary[i][j].componentID).available = stepDictionary[i][j].componentStatus.available; } else if (timeStep.GetThread(stepDictionary[i][j].componentID) != null) { if (stepDictionary[i][j].componentStatus.payload != null) { timeStep.GetThread(stepDictionary[i][j].componentID).DisablePackages(); for (int k = 0; k < stepDictionary[i][j].componentStatus.payload.Length; k++) { for (int l = 0; l < i; l++) { if (timeSteps[l].GetThread(stepDictionary[i][j].componentID).ContainsPackage(stepDictionary[i][j].componentStatus.payload[k]) == false) { PackageData package = new PackageData(); package.active = false; package.id = stepDictionary[i][j].componentStatus.payload[k]; timeSteps[l].GetThread(stepDictionary[i][j].componentID).packages.Add(package); } } if (timeStep.GetThread(stepDictionary[i][j].componentID).ContainsPackage(stepDictionary[i][j].componentStatus.payload[k])) { timeStep.GetThread(stepDictionary[i][j].componentID).GetPackage(stepDictionary[i][j].componentStatus.payload[k]).active = true; } else { PackageData package = new PackageData(); package.active = true; package.id = stepDictionary[i][j].componentStatus.payload[k]; timeStep.GetThread(stepDictionary[i][j].componentID).packages.Add(package); } } } } else if (timeStep.GetConditional(stepDictionary[i][j].componentID) != null) { if (stepDictionary[i][j].componentStatus.current != -1) { timeStep.GetConditional(stepDictionary[i][j].componentID).current = stepDictionary[i][j].componentStatus.current; } } break; } } timeSteps.Add(timeStep); if (stopwatch.ElapsedMilliseconds > 1000 / 60) { stopwatch.Stop(); stopwatch.Reset(); yield return new WaitForEndOfFrame(); stopwatch.Start(); } } playerInteraction.playerInteraction_UI.playbackSlider.maxValue = maxStep; playerInteraction.playerInteraction_UI.loadingOverlay.ClosePanel(); playerInteraction.playerInteraction_UI.playbackControls.gameObject.SetActive(true); playerInteraction.playerInteraction_UI.stopSimulationButton.interactable = true; playerInteraction.playerInteraction_UI.stopSimulationButton.gameObject.SetActive(true); playerInteraction.playerInteraction_UI.pauseSimulationButton.interactable = true; playerInteraction.playerInteraction_UI.pauseSimulationButton.gameObject.SetActive(true); playerInteraction.playerInteraction_UI.playbackSlider.interactable = true; playerInteraction.playerInteraction_UI.playbackSlider.gameObject.SetActive(true); yield return PlaySimulation(maxStep); } else { yield return null; } }
private void NavigateToThread(ThreadData thread, int page) { if (thread == null) { MessageBox.Show("Could not locate valid thread.", ":(", MessageBoxButton.OK); return; } PhoneApplicationService.Current.State["Thread"] = thread; var frame = App.Current.RootVisual as PhoneApplicationFrame; if (frame != null) { string uri = App.Settings.ThreadViewStyle == AwfulSettings.ViewStyle.Horizontal ? "/ViewThread.xaml" : "/ThreadView.xaml"; string pageQuery = page > 0 ? "?Page=" + page : string.Empty; frame.Navigate(new Uri(uri + pageQuery, UriKind.RelativeOrAbsolute)); } }
public ZeusProcess(ZeusProcessType type, ZeusProcessStatusDelegate callback, params string[] args) { ProcessStartInfo si = new ProcessStartInfo(); if (args.Length > 0) { si.FileName = FileTools.ApplicationPath + "\\ZeusCmd.exe"; si.CreateNoWindow = true; si.UseShellExecute = false; si.RedirectStandardOutput = true; string cmdArgs = "-internaluse "; if (type == ZeusProcessType.ExecuteTemplate) { cmdArgs += "-t \"" + args[0] + "\""; } else if (type == ZeusProcessType.ExecuteSavedInput) { cmdArgs += "-i \"" + args[0] + "\""; } else if (type == ZeusProcessType.RecordTemplateInput) { cmdArgs += "-t \"" + args[0] + "\" -c \"" + args[1] + "\""; } else if (type == ZeusProcessType.ExecuteProject) { cmdArgs += "-p \"" + args[0] + "\""; } else if (type == ZeusProcessType.ExecuteProjectModule) { cmdArgs += "-p \"" + args[0] + "\" -m \"" + args[1] + "\""; } else if (type == ZeusProcessType.ExecuteProjectItem) { cmdArgs += "-p \"" + args[0] + "\" -ti \"" + args[1] + "\""; } else if (type == ZeusProcessType.RecordProjectItem) { //filename, instancePath, templateFilename //-internaluse -t "C:\projects\mygeneration\trunk\templates\HTML\HTML_DatabaseReport.csgen" -p "c:\PrjRoot.zprj" -rti "/PrjRoot/testInstance" cmdArgs += "-t \"" + args[2] + "\" -p \"" + args[0] + "\" -rti \"" + args[1] + "\""; } if (!string.IsNullOrEmpty(cmdArgs)) si.Arguments = cmdArgs; } Process process = new Process(); process.StartInfo = si; ParameterizedThreadStart ts = new ParameterizedThreadStart(Start); t = new Thread(ts); td = new ThreadData(callback, process, _id); }
public virtual void LoadThreadPageAsync(ThreadData thread, int pageNumber = 0, int postNumber = -1) { if (pageNumber < 0 || pageNumber > thread.MaxPages) { string error = string.Format("ThreadViewerViewModel: pageNumber {0} not in range 1 to {1}.", pageNumber, thread.MaxPages); Awful.Core.Event.Logger.AddEntry(error); Awful.Core.Event.Logger.AddEntry("Setting page index to 0 instead, to fetch last page..."); pageNumber = 0; } this.IsPageLoading = true; if (thread.ThreadTitle == null) { this.ThreadTitle = ((SAThread)thread).ThreadURL; } else { this.ThreadTitle = thread.ThreadTitle; } this.Posts = null; this._CurrentPage = pageNumber; this._TotalPages = thread.MaxPages; this._currentThreadData = thread; // else fetch page from cache SAThread saThread = thread as SAThread; SAThreadPage tPage = null; if (this.CurrentUserID == 0) { tPage = this.LoadFromDatabase(saThread, pageNumber); } if (tPage == null) { tPage = new SAThreadPage(saThread, pageNumber, this.CurrentUserID); this._Cancellable = SAThreadPageFactory.BuildAsync((result, page) => { postNumber = thread.LastViewedPostIndex; thread.LastViewedPageIndex = 0; thread.LastViewedPostIndex = -1; ThreadPool.QueueUserWorkItem(state => { this.HandleResult(result, page, postNumber); }, null); }, tPage); } else { ThreadPool.QueueUserWorkItem(state => { this.HandleResult(Awful.Core.Models.ActionResult.Success, tPage, postNumber); }, null); } }
public EventsThreadRow(FrameGroup group, ThreadDescription desc, ThreadData data) { Description = desc; EventData = data; Group = group; MaxDepth = 1; List <EventNode> rootCategories = new List <EventNode>(); List <EventNode> nodesToProcess = new List <EventNode>(); foreach (EventFrame frame in data.Events) { // Fill holes in timeline from regular events (not categories) // ------------------------------------------------------------------------------------------------------ const double thresholdMs = 0.1; EventTree categoriesTree = frame.CategoriesTree; rootCategories.Clear(); foreach (EventNode node in frame.CategoriesTree.Children) { rootCategories.Add(node); } if (rootCategories.Count != 0) { nodesToProcess.Clear(); foreach (EventNode node in frame.Root.Children) { nodesToProcess.Add(node); } while (nodesToProcess.Count > 0) { EventNode node = nodesToProcess[0]; nodesToProcess.RemoveAt(0); bool nodeIntersectWithCategories = false; foreach (EventNode categoryNode in rootCategories) { // drop nodes less than thresholdMs ms if (node.Entry.Duration < thresholdMs) { nodeIntersectWithCategories = true; break; } // node is entirely inside the categoryNode if (node.Entry.Start >= categoryNode.Entry.Start && node.Entry.Finish <= categoryNode.Entry.Finish) { nodeIntersectWithCategories = true; break; } // node is partially inside the categoryNode if (node.Entry.Intersect(categoryNode.Entry)) { foreach (EventNode tmp in node.Children) { nodesToProcess.Add(tmp); } nodeIntersectWithCategories = true; break; } } if (nodeIntersectWithCategories == false && node.Entry.Duration >= thresholdMs) { // node is not intersect with any categoryNode (add to category tree) EventNode fakeCategoryNode = new EventNode(frame.CategoriesTree, node.Entry); node.Entry.SetOverrideColor(GenerateColorFromString(node.Entry.Description.FullName)); rootCategories.Add(fakeCategoryNode); frame.CategoriesTree.Children.Add(fakeCategoryNode); } } } // ------------------------------------------------------------------------------------------------------ MaxDepth = Math.Max(frame.CategoriesTree.Depth, MaxDepth); } }
public void HandleThread(ThreadData entry) { this.CurrentThreadId = entry.ThreadId; this.AddLine(this.Formatter.FormatThread(entry, this.Filters), 0); }
private static Texture2D ThreadedScale(Texture2D tex, int newWidth, int newHeight, bool useBilinear, bool flipH, bool flipV) { texColors = tex.GetPixels(); newColors = new Color[newWidth * newHeight]; if (useBilinear) { ratioX = 1.0f / ((float)newWidth / (tex.width - 1)); ratioY = 1.0f / ((float)newHeight / (tex.height - 1)); } else { ratioX = ((float)tex.width) / newWidth; ratioY = ((float)tex.height) / newHeight; } w = tex.width; w2 = newWidth; var cores = Mathf.Min(SystemInfo.processorCount, newHeight); var slice = newHeight / cores; finishCount = 0; if (mutex == null) { mutex = new Mutex(false); } if (cores > 1) { int i = 0; ThreadData threadData; for (i = 0; i < cores - 1; i++) { threadData = new ThreadData(slice * i, slice * (i + 1)); ParameterizedThreadStart ts = useBilinear ? new ParameterizedThreadStart(BilinearScale) : new ParameterizedThreadStart(PointScale); Thread thread = new Thread(ts); thread.Start(threadData); } threadData = new ThreadData(slice * i, newHeight); if (useBilinear) { BilinearScale(threadData); } else { PointScale(threadData); } while (finishCount < cores) { Thread.Sleep(1); } } else { ThreadData threadData = new ThreadData(0, newHeight); if (useBilinear) { BilinearScale(threadData); } else { PointScale(threadData); } } tex.Resize(newWidth, newHeight); tex.SetPixels(newColors); tex.Apply(); Texture2D orig = new Texture2D(tex.width, tex.height); if (flipV) { int xN = tex.width; int yN = tex.width; for (int i = 0; i < xN; i++) { for (int j = 0; j < yN; j++) { // tex.SetPixel(xN - i - 1, j, orig.GetPixel(i, j)); orig.SetPixel(i, yN - j - 1, tex.GetPixel(i, j)); } } orig.Apply(); } else if (flipH) { int xN = tex.width; int yN = tex.width; for (int i = 0; i < xN; i++) { for (int j = 0; j < yN; j++) { // tex.SetPixel(xN - i - 1, j, orig.GetPixel(i, j)); orig.SetPixel(xN - i - 1, j, tex.GetPixel(i, j)); } } orig.Apply(); } else { orig = tex; } return(orig); }
public ListableThreadData(ThreadData threadData) { this.ThreadId = threadData.ThreadId; this.DisplayText = string.Format("{0:0000} - {2} logs, name = \"{1}\"", threadData.ThreadId, threadData.ThreadName, threadData.Entries.Length); this.OriginalData = threadData; }
/// <summary> /// Set thread information /// </summary> private void SetThreadInformations() { ThreadData = new ThreadData(Report.DiagnosticStack); ThreadInformations = ThreadData.ThreadInformations; MainThread = ThreadData.MainThread; }
ThreadData GenerateSamplingThread(FrameGroup group, ThreadData thread) { List <Entry> entries = new List <Entry>(); List <Entry> stack = new List <Entry>(); List <EventFrame> frames = new List <EventFrame>(); Callstack current = new Callstack(); for (int csIndex = 0; csIndex < thread.Callstacks.Count; ++csIndex) { Callstack callstack = thread.Callstacks[csIndex]; if (current.Start == callstack.Start) { continue; } int matchCount = 0; for (int i = 0; i < Math.Min(current.Count, callstack.Count); ++i, ++matchCount) { if (current[i].Name != callstack[i].Name) { break; } } for (int i = matchCount; i < stack.Count; ++i) { stack[i].Finish = callstack.Start; } stack.RemoveRange(matchCount, stack.Count - matchCount); if (stack.Count == 0 && matchCount > 0) { FrameHeader h = new FrameHeader() { Start = entries.Min(e => e.Start), Finish = entries.Max(e => e.Finish), }; frames.Add(new EventFrame(h, entries, group)); entries.Clear(); } for (int i = matchCount; i < callstack.Count; ++i) { Entry entry = new Entry(new EventDescription(callstack[i].Name), callstack.Start, long.MaxValue); entries.Add(entry); stack.Add(entry); } current = callstack; } foreach (Entry e in stack) { e.Finish = current.Start; } FrameHeader header = new FrameHeader() { Start = thread.Callstacks.First().Start, Finish = thread.Callstacks.Last().Start, }; frames.Add(new EventFrame(header, entries, group)); ThreadData result = new ThreadData(null) { Events = frames }; return(result); }
/// <summary> /// Diese Methode stellt eine Threadmessage dar und ruft sich rekursiv für alle /// Child-Nodes der entsprechenden Threadmessage auf. /// </summary> /// <param name="row"></param> /// <param name="nDepth"></param> private void AddThreadMessage(ThreadData.ThreadRow row, int nDepth) { DataRow datarow = m_Data.NewRow(); datarow["Title"] = row["Title"]; datarow["Text"] = row["Text"]; datarow["Author"] = row["Author"]; datarow["Email"] = row["Email"]; datarow["UserId"] = row["UserId"]; datarow["Id"] = row["Id"]; datarow["Parent"] = row["Parent"]; datarow["DateTime"] = row["DateTime"]; datarow["Depth"] = nDepth; m_Data.Rows.Add(datarow); // Rekursiver Aufruf aller Child-Nodes. foreach (ThreadData.ThreadRow r in row.GetChildRows("ThreadThread")) { AddThreadMessage(r, nDepth+1); } }
public void ReplyAsync(ThreadData data, string message, Action<Awful.Core.Models.ActionResult> result) { replySvc.ReplyAsync(data, message, result); }
internal static CSDataProvider GetDB(string strContext) { if (_threadData == null) _threadData = new ThreadData(); return _threadData.GetDB(strContext); }
/// <summary> /// notification thread pool, state of the current thread is busy /// </summary> /// <param name="pThreadData"></param> private void BusyNotify(ThreadData pThreadData) { lock (this) { pThreadData.bFree = false; } }
public GDMesh BuildThreaded() { DateTime now = DateTime.Now; bool flag = false; this.checkNormals = (this.m.normals != null) && (this.m.normals.Length == this.m.vertexCount); this.checkTangents = (this.m.tangents != null) && (this.m.tangents.Length == this.m.vertexCount); this.checkColors = (this.m.colors != null) && (this.m.colors.Length == this.m.vertexCount); this.checkUV = (this.m.uv != null) && (this.m.uv.Length == this.m.vertexCount); this.checkUV1 = (this.m.uv2 != null) && (this.m.uv2.Length == this.m.vertexCount); this.checkUV2 = (this.m.uv2 != null) && (this.m.uv2.Length == this.m.vertexCount); this.checkBones = (this.m.boneWeights != null) && (this.m.boneWeights.Length == this.m.vertexCount); this.checkBinds = (this.m.bindposes != null) && (this.m.bindposes.Length > 0); this.locker = new ReaderWriterLockSlim(); this.verts = this.m.vertices; this.normals = this.m.normals; this.tangents = this.m.tangents; this.colors = this.m.colors; this.uv = this.m.uv; this.uv1 = this.m.uv2; this.uv2 = this.m.uv2; this.bones = this.m.boneWeights; this.binds = this.m.bindposes; if (this.mutex == null) { this.mutex = new Mutex(false); } if (this._gdmesh == null) { flag = true; this._gdmesh = new GDMesh(this.m); } this._gdmesh.vertexCount = this.m.vertexCount; this.vertices = new GDMesh.Vertex[this.m.vertexCount]; int num = Mathf.Min(SystemInfo.processorCount * 30, this.m.vertexCount); if (num <= 0) { num = 1; } int num2 = this.m.vertexCount / num; this.threads = new Thread[num]; if (flag) { try { int index = 0; while (index < (num - 1)) { ThreadData data = new ThreadData(num2 * index, num2 * (index + 1)); this.threads[index] = new Thread(new ParameterizedThreadStart(this.HandleVertices)); this.threads[index].Priority = System.Threading.ThreadPriority.Highest; this.threads[index].Start(data); index++; } ThreadData parameter = new ThreadData(num2 * index, this.m.vertexCount); this.threads[index] = new Thread(new ParameterizedThreadStart(this.HandleVertices)); this.threads[index].Start(parameter); this.threads[index].Priority = System.Threading.ThreadPriority.Highest; foreach (Thread thread in this.threads) { thread.Join(); } this._gdmesh.vertices.Sort(delegate(GDMesh.Vertex x, GDMesh.Vertex y) { if (x.Traits.ID < y.Traits.ID) { return(-1); } if (x.Traits.ID > y.Traits.ID) { return(1); } return(0); }); } catch (Exception) { } } else { for (int j = 0; j < this._gdmesh.vertices.Count; j++) { IndexBuffer buffer = this._gdmesh.relatedVertices[this._gdmesh.vertices[j].Traits.hashCode]; foreach (int num5 in buffer) { this.vertices[num5] = this._gdmesh.vertices[j]; } } } if (!flag) { if (this._gdmesh == null) { this._gdmesh = new GDMesh(this.m); } if (this._gdmesh.faces == null) { this._gdmesh.faces = new List <GDMesh.Face>(this.m.triangles.Length / 3); } if (this._gdmesh.edges == null) { this._gdmesh.edges = new List <GDMesh.Edge>(this.m.triangles.Length); } if (this._gdmesh.elements == null) { this._gdmesh.elements = new List <GDMesh.Element>(this.m.subMeshCount); } this._gdmesh.faces.Clear(); this._gdmesh.edges.Clear(); this._gdmesh.elements.Clear(); } this.finishedCount = 0; DateTime time2 = DateTime.Now; this.subMeshCount = this.m.subMeshCount; this.triangles = this.m.triangles; this.subTriangles = new List <int[]>(this.subMeshCount); for (int i = 0; i < this.subMeshCount; i++) { this.subTriangles.Add(this.m.GetTriangles(i)); } this.BuildDataStructure(0); if (this.checkBinds) { this._gdmesh.bindposes = new List <Matrix4x4>(this.m.bindposes); } this._gdmesh.isBuilt = true; GDManager.activeController.UpdateCollider(); return(this._gdmesh); }
/// <summary> /// notification thread pool, state of the current thread is finish /// </summary> /// <param name="pThreadData"></param> private void FinishNotify(ThreadData pThreadData) { lock (this) { pThreadData.bFree = true; pThreadData.WaitHandle.Reset(); } }
public void BuildDataStructure(object num) { int num2 = 0; if ((this.subMeshCount == 1) || (this.subMeshCount == 0)) { int num3 = Mathf.Min(SystemInfo.processorCount * 30, this.triangles.Length); if (num3 <= 0) { num3 = 1; } int num4 = (this.triangles.Length / num3) - ((this.triangles.Length / num3) % 3); this.threads = new Thread[num3]; GDMesh.Element item = new GDMesh.Element(); int index = 0; while (index < (num3 - 1)) { ThreadData data = new ThreadData(num4 * index, num4 * (index + 1)); data.custom = item; data._gdmesh = this._gdmesh; data.custom2 = this.triangles; data.custom3 = 0; data.custom4 = 0; this.threads[index] = new Thread(new ParameterizedThreadStart(this.ProcessMesh)); this.threads[index].Priority = System.Threading.ThreadPriority.Highest; this.threads[index].Start(data); index++; } ThreadData parameter = new ThreadData(num4 * index, this.triangles.Length); parameter.custom = item; parameter._gdmesh = this._gdmesh; parameter.custom2 = this.triangles; parameter.custom3 = 0; parameter.custom4 = num2; this.threads[index] = new Thread(new ParameterizedThreadStart(this.ProcessMesh)); this.threads[index].Start(parameter); this.threads[index].Priority = System.Threading.ThreadPriority.Highest; foreach (Thread thread in this.threads) { thread.Join(); } this._gdmesh.faces.Sort(delegate(GDMesh.Face x, GDMesh.Face y) { if (x.Traits.ID < y.Traits.ID) { return(-1); } if (x.Traits.ID > y.Traits.ID) { return(1); } return(0); }); item.Index = 0; this._gdmesh.Elements.Add(item); } else { for (int i = 0; i < this.subMeshCount; i++) { int num7 = Mathf.Min(SystemInfo.processorCount * 30, this.subTriangles[i].Length); if (num7 <= 0) { num7 = 1; } int num8 = (this.subTriangles[i].Length / num7) - ((this.subTriangles[i].Length / num7) % 3); this.threads = new Thread[num7]; GDMesh.Element element2 = new GDMesh.Element(); int num9 = 0; while (num9 < (num7 - 1)) { ThreadData data3 = new ThreadData(num8 * num9, num8 * (num9 + 1)); data3.custom = element2; data3._gdmesh = this._gdmesh; data3.custom2 = this.subTriangles[i]; data3.custom3 = i; data3.custom4 = num2; this.threads[num9] = new Thread(new ParameterizedThreadStart(this.ProcessMesh)); this.threads[num9].Priority = System.Threading.ThreadPriority.Highest; this.threads[num9].Start(data3); num9++; } ThreadData data4 = new ThreadData(num8 * num9, this.subTriangles[i].Length); data4.custom = element2; data4._gdmesh = this._gdmesh; data4.custom2 = this.subTriangles[i]; data4.custom3 = i; data4.custom4 = num2; this.threads[num9] = new Thread(new ParameterizedThreadStart(this.ProcessMesh)); this.threads[num9].Start(data4); this.threads[num9].Priority = System.Threading.ThreadPriority.Highest; foreach (Thread thread2 in this.threads) { thread2.Join(); } num2 += this.subTriangles[i].Length / 3; element2.Index = i; this._gdmesh.Elements.Add(element2); } this._gdmesh.faces.Sort(delegate(GDMesh.Face x, GDMesh.Face y) { if (x.Traits.ID < y.Traits.ID) { return(-1); } if (x.Traits.ID > y.Traits.ID) { return(1); } return(0); }); } this.finishedCount++; }
/// <summary> /// create a thread pool thread belongs /// </summary> /// <returns>If the current thread pool has been created to return false, otherwise true</returns> public bool Create() { if (this.m_bStarted == true) return false; this.m_bPoolIsDestroying = false; m_hNotifyShutdown.Reset(); for (int nIndex = 0; nIndex < this.m_nPoolSize; nIndex++) { ThreadData pThreadData = new ThreadData(); pThreadData.bFree = true; pThreadData.WaitHandle = new ManualResetEvent(false); pThreadData.hThread = new Thread(ThreadProc); pThreadData.hThread.IsBackground = true; pThreadData.dwThreadId = nIndex + 1; m_threads.Add(pThreadData); pThreadData.hThread.Start(pThreadData); } return true; }
public static async Task Main() { if (!EngineConstants.GenerateBrPromotions) { Console.WriteLine("Generation of underpromotions is disabled!"); } ChessBoardInstances.Init(8); ThreadData.InitInstances(8); var threadNr = 0; var kiwi = new PerftWorker("Kiwi-pete", threadNr++); kiwi.AddPosition("r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -", 4085603, 4); var ep = new PerftWorker("EP", threadNr++); ep.AddPosition("3k4/3p4/8/K1P4r/8/8/8/8 b - - 0 1", 20757544, 7); ep.AddPosition("8/8/4k3/8/2p5/8/B2P2K1/8 w - - 0 1", 14047573, 7); ep.AddPosition("8/8/1k6/2b5/2pP4/8/5K2/8 b - d3 0 1", 21190412, 7); var castling = new PerftWorker("Castling", threadNr++); castling.AddPosition("5k2/8/8/8/8/8/8/4K2R w K - 0 1", 661072, 6); castling.AddPosition("3k4/8/8/8/8/8/8/R3K3 w Q - 0 1", 803711, 6); castling.AddPosition("r3k2r/1b4bq/8/8/8/8/7B/R3K2R w KQkq - 0 1", 1274206, 4); castling.AddPosition("r3k2r/8/3Q4/8/8/5q2/8/R3K2R b KQkq - 0 1", 1720476, 4); var promotion = new PerftWorker("Promotion", threadNr++); promotion.AddPosition("2K2r2/4P3/8/8/8/8/8/3k4 w - - 0 1", 60651209, 7); promotion.AddPosition("4k3/1P6/8/8/8/8/K7/8 w - - 0 1", 3742283, 7); promotion.AddPosition("8/P1k5/K7/8/8/8/8/8 w - - 0 1", 1555980, 7); var mate = new PerftWorker("Stalemate and Checkmate", threadNr++); mate.AddPosition("8/8/1P2K3/8/2n5/1q6/8/5k2 b - - 0 1", 6334638, 6); mate.AddPosition("K1k5/8/P7/8/8/8/8/8 w - - 0 1", 15453, 7); mate.AddPosition("8/k1P5/8/1K6/8/8/8/8 w - - 0 1", 2518905, 8); mate.AddPosition("8/8/2k5/5q2/5n2/8/5K2/8 b - - 0 1", 3114998, 6); var perft = new PerftWorker("Perft", threadNr); perft.AddPosition(ChessConstants.FenStart, 4865609, 5); var kiwiTask = Task.Run(() => kiwi.Run()); var epTask = Task.Run(() => ep.Run()); var castlingTask = Task.Run(() => castling.Run()); var promotionTask = Task.Run(() => promotion.Run()); var mateTask = Task.Run(() => mate.Run()); var perftTask = Task.Run(() => perft.Run()); await kiwiTask; await epTask; await castlingTask; await promotionTask; await mateTask; await perftTask; Console.WriteLine(); Console.WriteLine("Done"); }
static void Main(string[] args) { bool multiThreaded = true; if (args.Length < 2) { Console.WriteLine("Usage: PatchGen [distribution folder] [output folder]"); return; } if (!Directory.Exists(args[0])) { Console.WriteLine(" Distribution Folder: {0} does not exist", args[0]); return; } try { if (Directory.Exists(args[1])) { Directory.Delete(args[1], true); } Directory.CreateDirectory(args[1]); } catch (Exception ex) { Console.WriteLine("Failed to setup output folder\n" + ex.ToString()); return; } DateTime start = DateTime.Now; bool error = false; s_inputPath = args[0]; s_outputPath = args[1]; List <string> hashManifest = new List <string>(); List <ThreadData> threads = new List <ThreadData>(); string[] files = Directory.GetFiles(args[0], "*.*", SearchOption.AllDirectories); foreach (string file in files) { if (multiThreaded) { ThreadData td = new ThreadData(); td.thread = new Thread(new ParameterizedThreadStart(FileProcessThread)); td.thread.Name = file; td.thread.Start(td); threads.Add(td); } else { Console.WriteLine("Processing file: " + file); string manifestEntry = ProcessFile(file); if (manifestEntry == null) { error = true; } else { hashManifest.Add(manifestEntry); } } } if (multiThreaded) { foreach (ThreadData td in threads) { Console.WriteLine("Waiting for file: " + td.thread.Name); td.thread.Join(); if (td.manifestEntry == null) { error = true; } else { hashManifest.Add(td.manifestEntry); } } } if (error) { Console.WriteLine("Not generating manifest due to errors"); } else { // Generate the manifest file try { File.WriteAllLines(args[1] + "/manifest", hashManifest.ToArray()); } catch (Exception ex) { Console.WriteLine("Failed to write manifest file\n" + ex.ToString()); } } TimeSpan s = DateTime.Now - start; Console.WriteLine("TotalTime: {0} seconds", s.TotalSeconds); System.Diagnostics.Debug.WriteLine("TotalTime: {0} seconds", s.TotalSeconds); }
private static void ThreadedScale(Texture2D tex, int newWidth, int newHeight, bool useBilinear) { texColors = tex.GetPixels(); newColors = new Color[newWidth * newHeight]; if (useBilinear) { ratioX = 1.0f / ((float)newWidth / (tex.width - 1)); ratioY = 1.0f / ((float)newHeight / (tex.height - 1)); } else { ratioX = ((float)tex.width) / newWidth; ratioY = ((float)tex.height) / newHeight; } w = tex.width; w2 = newWidth; var cores = Mathf.Min(SystemInfo.processorCount, newHeight); var slice = newHeight / cores; finishCount = 0; if (mutex == null) { mutex = new Mutex(false); } if (cores > 1) { int i = 0; ThreadData threadData; for (i = 0; i < cores - 1; i++) { threadData = new ThreadData(slice * i, slice * (i + 1)); ParameterizedThreadStart ts = useBilinear ? new ParameterizedThreadStart(BilinearScale) : new ParameterizedThreadStart(PointScale); Thread thread = new Thread(ts); thread.Start(threadData); } threadData = new ThreadData(slice * i, newHeight); if (useBilinear) { BilinearScale(threadData); } else { PointScale(threadData); } while (finishCount < cores) { Thread.Sleep(1); } } else { ThreadData threadData = new ThreadData(0, newHeight); if (useBilinear) { BilinearScale(threadData); } else { PointScale(threadData); } } // 回転の修正 最終的に拡縮済みのピクセルリストを配置しなおして回転したとする Color[] colors = new Color[newWidth * newHeight]; for (int posx = 0; posx < newWidth; ++posx) { for (int posy = newHeight - 1; posy >= 0; --posy) { int index = posy * newWidth + posx; colors[(((newWidth - 1) - posx) * newHeight) + posy] = newColors[index]; } } // アス比は維持するの前提 if (newWidth > newHeight) { tex.Resize(newHeight, newWidth); } else { tex.Resize(newWidth, newHeight); } //tex.Resize(newWidth, newHeight); tex.SetPixels(colors); //newColors); tex.Apply(); }
protected void OnMenuOpening(object sender, ContextMenuOpeningEventArgs e) { RadDataBoundListBoxItem focused = e.FocusedElement as RadDataBoundListBoxItem; if (focused == null) { e.Cancel = true; return; } else { ThreadData thread = focused.DataContext as ThreadData; this.SelectedThread = thread; } }
List <EventsThreadRow> GenerateThreadRows(FrameGroup group) { id2row.Clear(); List <EventsThreadRow> eventThreads = new List <EventsThreadRow>(); for (int i = 0; i < Math.Min(group.Board.Threads.Count, group.Threads.Count); ++i) { ThreadData data = group.Threads[i]; ThreadDescription thread = data.Description; if (thread.IsIdle) { continue; } bool threadHasData = false; if (data.Events != null) { double duration = 0.0; foreach (EventFrame frame in data.Events) { duration += frame.Duration; if (duration > MIN_THREAD_ACCUMULATED_DURATION) { threadHasData = true; break; } } } if (thread.Origin == ThreadDescription.Source.Core) { threadHasData = true; } if (threadHasData) { EventsThreadRow row = new EventsThreadRow(group, thread, data, Settings); eventThreads.Add(row); id2row.Add(row.Description.ThreadIndex, row); row.EventNodeHover += Row_EventNodeHover; row.EventNodeSelected += Row_EventNodeSelected; } if (GenerateSamplingThreads && data.Callstacks != null && data.Callstacks.Count > 3) { ThreadData samplingData = GenerateSamplingThread(group, data); EventsThreadRow row = new EventsThreadRow(group, new ThreadDescription() { Name = thread.Name + " [Sampling]", Origin = ThreadDescription.Source.Sampling }, samplingData, Settings); eventThreads.Add(row); row.EventNodeHover += Row_EventNodeHover; row.EventNodeSelected += Row_EventNodeSelected; } } return(SortRows(eventThreads)); }
static async Task ThreadedScale(Texture2D texture, int newWidth, int newHeight, bool useBilinear) { //early check: if (texture.width == newWidth && texture.height == newHeight) { //unnecessary runs proved to produce invalid textures, so let's not do that return; } // using (ShaderJobData jobData = new ShaderJobData()) { try { jobData.texColors = texture.GetPixels(); jobData.newColors = new Color[newWidth * newHeight]; if (useBilinear) { jobData.ratioX = 1f / ((float)newWidth / (texture.width - 1)); jobData.ratioY = 1f / ((float)newHeight / (texture.height - 1)); } else { jobData.ratioX = ((float)texture.width) / newWidth; jobData.ratioY = ((float)texture.height) / newHeight; } jobData.w = texture.width; jobData.w2 = newWidth; var cores = math.min(SystemInfo.processorCount, newHeight); var slice = newHeight / cores; if (cores > 1) { int i = 0; //run tasks on other threads: Task[] tasks = new Task[cores]; for (i = 0; i < cores; i++) { ThreadData threadData = new ThreadData(slice * i, slice * (i + 1)); tasks[i] = ( Task.Run(() => { try { if (useBilinear) { BilinearScale(threadData, jobData); } else { PointScale(threadData, jobData); } } catch (System.Exception ex) { Debug.LogException(ex); } }) ); } //wait until all other tasks completed: await Task.WhenAll(tasks); } else { ThreadData threadData = new ThreadData(0, newHeight); if (useBilinear) { BilinearScale(threadData, jobData); } else { PointScale(threadData, jobData); } } texture.Resize(newWidth, newHeight); texture.SetPixels(jobData.newColors); texture.Apply(); } catch (System.Exception ex) { Debug.LogException(ex); } } }
private static void ThreadedScale(Texture2D tex, int newWidth, int newHeight, bool useBilinear) { texColors = tex.GetPixels32(); newColors = new Color32[newWidth * newHeight]; if (useBilinear) { ratioX = 1.0f / ((float)newWidth / (tex.width - 1)); ratioY = 1.0f / ((float)newHeight / (tex.height - 1)); } else { ratioX = ((float)tex.width) / newWidth; ratioY = ((float)tex.height) / newHeight; } w = tex.width; w2 = newWidth; var cores = Mathf.Min(SystemInfo.processorCount, newHeight); var slice = newHeight / cores; finishCount = 0; if (mutex == null) { mutex = new Mutex(false); } if (cores > 1) { int i = 0; ThreadData threadData; for (i = 0; i < cores - 1; i++) { threadData = new ThreadData(slice * i, slice * (i + 1)); ParameterizedThreadStart ts = useBilinear ? new ParameterizedThreadStart(BilinearScale) : new ParameterizedThreadStart(PointScale); Thread thread = new Thread(ts); thread.Start(threadData); } threadData = new ThreadData(slice * i, newHeight); if (useBilinear) { BilinearScale(threadData); } else { PointScale(threadData); } while (finishCount < cores) { Thread.Sleep(1); } } else { ThreadData threadData = new ThreadData(0, newHeight); if (useBilinear) { BilinearScale(threadData); } else { PointScale(threadData); } } tex.Resize(newWidth, newHeight); tex.SetPixels32(newColors); tex.Apply(); texColors = null; newColors = null; }
public static void Print() { if (!Enabled) { return; } var totalMoveCount = ChessBoardUtil.CalculateTotalMoveCount(); Console.WriteLine("AB-nodes " + AbNodes); Console.WriteLine("PV-nodes " + _pvNodes + " = 1/" + (_pvNodes + _cutNodes + _allNodes) / _pvNodes); Console.WriteLine("Cut-nodes " + _cutNodes); PrintPercentage("Cut 1 ", FailHigh[0], _cutNodes - FailHigh[0]); PrintPercentage("Cut 2 ", FailHigh[1], _cutNodes - FailHigh[1]); PrintPercentage("Cut 3 ", FailHigh[2], _cutNodes - FailHigh[2]); Console.WriteLine("All-nodes " + _allNodes); Console.WriteLine("Q-nodes " + QNodes); Console.WriteLine("See-nodes " + SeeNodes); Console.WriteLine("Evaluated " + EvalNodes); Console.WriteLine("Moves " + totalMoveCount); var threadData = ThreadData.GetInstance(0); Console.WriteLine("### Caches #######"); PrintPercentage("TT ", TtHits, TtMisses); Console.WriteLine("usage " + TtUtil.GetUsagePercentage() / 10 + "%"); PrintPercentage("Eval ", EvalCacheHits, EvalCacheMisses); Console.WriteLine("usage " + Util.GetUsagePercentage(threadData.EvalCache) + "%"); PrintPercentage("Pawn eval ", PawnEvalCacheHits, PawnEvalCacheMisses); Console.WriteLine("usage " + Util.GetUsagePercentage(threadData.PawnCache) + "%"); PrintPercentage("Material ", MaterialCacheHits, MaterialCacheMisses); Console.WriteLine("usage " + Util.GetUsagePercentage(threadData.MaterialCache) + "%"); Console.WriteLine("## Best moves #####"); Console.WriteLine("TT " + _bestMoveTt); Console.WriteLine("TT-upper " + _bestMoveTtUpper); Console.WriteLine("TT-lower " + _bestMoveTtLower); Console.WriteLine("Win-cap " + _bestMoveWinningCapture); Console.WriteLine("Los-cap " + _bestMoveLosingCapture); Console.WriteLine("Promo " + _bestMovePromotion); Console.WriteLine("Killer1 " + _bestMoveKiller1); Console.WriteLine("Killer2 " + _bestMoveKiller2); Console.WriteLine("Killer1 evasi " + _bestMoveKillerEvasive1); Console.WriteLine("Killer2 evasi " + _bestMoveKillerEvasive2); Console.WriteLine("Counter " + _bestMoveCounter); Console.WriteLine("Other " + _bestMoveOther); Console.WriteLine("### Outcome #####"); Console.WriteLine("Checkmate " + MateCount); Console.WriteLine("Stalemate " + StaleMateCount); Console.WriteLine("Repetitions " + Repetitions + "(" + _repetitionTests + ")"); Console.WriteLine("### Extensions #####"); Console.WriteLine("Check " + CheckExtensions); Console.WriteLine("### Pruning #####"); PrintPercentage("Null-move ", NullMoveHit, NullMoveMiss); PrintDepthTotals("Static nmp ", StaticNullMoved, false); PrintDepthTotals("Razored ", Razored, false); PrintDepthTotals("Futile ", Futile, false); PrintDepthTotals("LMP ", Lmped, false); }