Skip to content

Commit

Permalink
utility fn
Browse files Browse the repository at this point in the history
  • Loading branch information
rms80 committed May 20, 2018
1 parent 4a59fcb commit 2244af3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/SafeCollections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ public void SafeAdd(T value)
spinlock.Exit();
}


public void SafeOperation(Action<List<T>> opF)
{
bool lockTaken = false;
while (lockTaken == false)
spinlock.Enter(ref lockTaken);

opF(List);

spinlock.Exit();
}


public List<T> Result {
get { return List; }
}
Expand Down
8 changes: 8 additions & 0 deletions io/SVGWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ public static void QuickWrite(List<GeneralPolygon2d> polygons1, string color1, f



public static void QuickWrite(DGraph2 graph, string sPath, float line_width = 1)
{
SVGWriter writer = new SVGWriter();
Style style = SVGWriter.Style.Outline("black", line_width);
writer.AddGraph(graph, style);
writer.Write(sPath);
}




Expand Down

0 comments on commit 2244af3

Please sign in to comment.