aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-01-14 08:01:10 +0100
committerj-p <jp_bruyere@hotmail.com>2021-02-06 20:28:02 +0100
commit0f08742ef206f006db97a8d2bc67b1c4cae34deb (patch)
treef17e9d47d7a0cac05c5041b7110d5e887f9dc229
parentd3b306830e774c1998793fe28eb4d53e39a7e665 (diff)
planned Queue<T> capacity set to INIT_QUEUE_CAPACITY constant in Interface
-rw-r--r--Crow/src/Interface.cs17
1 files 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;
/// <summary>Time interval in milisecond between Updates of the interface</summary>
public static int UPDATE_INTERVAL = 5;
/// <summary>Crow configuration root path</summary>
@@ -402,11 +403,11 @@ namespace Crow
/// </summary>
public Dictionary<string,object> Ressources = new Dictionary<string, object>();
/// <summary>The Main layouting queue.</summary>
- public Queue<LayoutingQueueItem> LayoutingQueue = new Queue<LayoutingQueueItem> ();
+ public Queue<LayoutingQueueItem> LayoutingQueue = new Queue<LayoutingQueueItem> (INIT_QUEUE_CAPACITY);
/// <summary>Store discarded lqi between two updates</summary>
public Queue<LayoutingQueueItem> DiscardQueue;
/// <summary>Main drawing queue, holding layouted controls</summary>
- public Queue<Widget> ClippingQueue = new Queue<Widget>();
+ public Queue<Widget> ClippingQueue = new Queue<Widget>(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
/// </summary>
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<LayoutingQueueItem> ();
+ DiscardQueue = new Queue<LayoutingQueueItem> (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