From 55214b441fb6c5180a3051ee38b5506859703981 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Thu, 14 Jan 2021 08:01:10 +0100 Subject: [PATCH] planned Queue capacity set to INIT_QUEUE_CAPACITY constant in Interface --- Crow/src/Interface.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index c54af96c..11417dec 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -252,10 +252,9 @@ namespace Crow while (!Glfw3.WindowShouldClose (hWin)) { Glfw3.PollEvents (); UpdateFrame (); - Thread.Sleep(1); } } - public virtual void UpdateFrame () { } + public virtual void UpdateFrame () { Thread.Sleep (1); } public virtual void Quit () => Glfw3.SetWindowShouldClose (hWin, 1); @@ -311,6 +310,8 @@ namespace Crow }*/ #region Static and constants + //initial capacity for layouting and clipping queues. + const int INIT_QUEUE_CAPACITY = 512; /// Time interval in milisecond between Updates of the interface public static int UPDATE_INTERVAL = 5; /// Crow configuration root path @@ -402,11 +403,11 @@ namespace Crow /// public Dictionary Ressources = new Dictionary(); /// The Main layouting queue. - public Queue LayoutingQueue = new Queue (); + public Queue LayoutingQueue = new Queue (INIT_QUEUE_CAPACITY); /// Store discarded lqi between two updates public Queue DiscardQueue; /// Main drawing queue, holding layouted controls - public Queue ClippingQueue = new Queue(); + public Queue ClippingQueue = new Queue(INIT_QUEUE_CAPACITY); //TODO:use object instead for complex copy paste public string Clipboard { get => Glfw3.GetClipboardString (hWin); @@ -710,6 +711,7 @@ namespace Crow /// Result: the Interface bitmap is drawn in memory (byte[] bmp) and a dirtyRect and bitmap are available /// public void Update(Context ctx = null){ + CrowThread[] tmpThreads; lock (CrowThreads) { tmpThreads = new CrowThread[CrowThreads.Count]; @@ -763,7 +765,7 @@ namespace Crow DbgLogger.StartEvent (DbgEvtType.Layouting); PerformanceMeasure.Begin (PerformanceMeasure.Kind.Layouting); - DiscardQueue = new Queue (); + DiscardQueue = new Queue (LayoutingQueue.Count); //Debug.WriteLine ("======= Layouting queue start ======="); LayoutingQueueItem lqi; while (LayoutingQueue.Count > 0) { @@ -1323,10 +1325,7 @@ namespace Crow // keyboardRepeatThread.Start (); } - public bool IsKeyDown (Key key) - { - return false; - } + public bool IsKeyDown (Key key) => Glfw3.GetKey (hWin, key) == InputAction.Press; #endregion #region Tooltip handling -- 2.47.3