From: Jean-Philippe Bruyère Date: Thu, 14 Jan 2021 07:01:10 +0000 (+0100) Subject: planned Queue capacity set to INIT_QUEUE_CAPACITY constant in Interface X-Git-Tag: v0.9.5-beta~103 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=0f08742ef206f006db97a8d2bc67b1c4cae34deb;p=jp%2Fcrow.git planned Queue capacity set to INIT_QUEUE_CAPACITY constant in Interface --- 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