Skip to content

Commit

Permalink
Merge pull request #2279 from GabeMx5/master
Browse files Browse the repository at this point in the history
Improved performances
  • Loading branch information
arkypita authored Jun 16, 2024
2 parents 340ad65 + cea12ff commit bdb90b6
Show file tree
Hide file tree
Showing 10 changed files with 427 additions and 283 deletions.
17 changes: 13 additions & 4 deletions LaserGRBL/Core/GrblCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ public void AbortProgram()

lock (this)
{
mQueue.Clear(); //flush the queue of item to send
ClearQueue(mQueue); //flush the queue of item to send
mQueue.Enqueue(new GrblCommand("M5")); //shut down laser
}
}
Expand Down Expand Up @@ -2679,10 +2679,19 @@ private void OnProgramEnd()
private bool InPause
{ get { return mMachineStatus != MacStatus.Run && mMachineStatus != MacStatus.Idle; } }

private void ClearQueue(bool sent)
private void ClearQueue(Queue<GrblCommand> queue)
{
foreach (GrblCommand command in queue)
{
command.Dispose();
}
queue.Clear();
}

private void ClearQueue(bool sent)
{
mQueue.Clear();
mPending.Clear();
ClearQueue(mQueue);
ClearQueue(mPending);
if (sent) mSent.Clear();
mRetryQueue = null;
}
Expand Down
9 changes: 7 additions & 2 deletions LaserGRBL/GrblCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private static void LoadAppropriateErrors(GrblCore.GrblVersionInfo value)
}
}

public partial class GrblCommand : ICloneable, IGrblRow
public partial class GrblCommand : ICloneable, IGrblRow, IDisposable
{
public class Element
{
Expand Down Expand Up @@ -474,7 +474,12 @@ public int ImageIndex

public override string ToString()
{ return this.mLine; }
}

public void Dispose()
{
LinkedDisplayList = null;
}
}

public class GrblMessage : IGrblRow
{
Expand Down
Loading

0 comments on commit bdb90b6

Please sign in to comment.