-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom task scheduler for serialization, fix batch size calc (#194)
* Add a custom task scheduler * Better usage, don't wait to enqueue to save to channels * Completely pre-cal batch size to avoid spinning issues * Try to fix cache counting * properly dispose things * format * clean up * adjust count and save on current thread * move batch it's own file * update a few packages * fix build and add batch tests
- Loading branch information
1 parent
a1b9030
commit 1fe1a54
Showing
25 changed files
with
274 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace Speckle.Sdk.Serialisation.V2.Send; | ||
|
||
public class Batch<T>(int capacity) : IHasSize | ||
where T : IHasSize | ||
{ | ||
#pragma warning disable IDE0032 | ||
private readonly List<T> _items = new(capacity); | ||
private int _batchSize; | ||
#pragma warning restore IDE0032 | ||
|
||
public void Add(T item) | ||
{ | ||
_items.Add(item); | ||
_batchSize += item.Size; | ||
} | ||
|
||
public void TrimExcess() | ||
{ | ||
_items.TrimExcess(); | ||
_batchSize = _items.Sum(x => x.Size); | ||
} | ||
|
||
public int Size => _batchSize; | ||
public List<T> Items => _items; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.