Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhathcock committed Dec 31, 2024
1 parent 550ee2b commit e1f1ade
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Add(T item)
_items.Add(item);
_batchSize += item.Size;
}

public void TrimExcess()
{
_items.TrimExcess();
Expand All @@ -32,7 +32,6 @@ public void TrimExcess()
public List<T> Items => _items;
}


public class SizeBatchingChannelReader<T>(
ChannelReader<T> source,
int batchSize,
Expand Down
7 changes: 6 additions & 1 deletion src/Speckle.Sdk/Api/Operations/Operations.Send.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ public async Task<SerializeProcessResults> Send2(

try
{
using var process = serializeProcessFactory.CreateSerializeProcess(url, streamId, authorizationToken, onProgressAction);
using var process = serializeProcessFactory.CreateSerializeProcess(
url,
streamId,
authorizationToken,
onProgressAction
);
var results = await process.Serialize(value, cancellationToken).ConfigureAwait(false);

receiveActivity?.SetStatus(SdkActivityStatusCode.Ok);
Expand Down
4 changes: 1 addition & 3 deletions src/Speckle.Sdk/Serialisation/V2/Send/PriorityScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Speckle.Sdk.Serialisation.V2.Send;

public sealed class PriorityScheduler(ThreadPriority priority, int maximumConcurrencyLevel)
: TaskScheduler,
IDisposable
public sealed class PriorityScheduler(ThreadPriority priority, int maximumConcurrencyLevel) : TaskScheduler, IDisposable
{
private readonly BlockingCollection<Task> _tasks = new();
private Thread[]? _threads;
Expand Down
27 changes: 15 additions & 12 deletions src/Speckle.Sdk/Serialisation/V2/Send/SerializeProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ public sealed class SerializeProcess(
SerializeProcessOptions? options = null
) : ChannelSaver<BaseItem>, ISerializeProcess
{
private readonly PriorityScheduler _highest = new( ThreadPriority.Highest, 2);
private readonly PriorityScheduler _belowNormal = new(
ThreadPriority.BelowNormal,
Environment.ProcessorCount * 3
);
private readonly PriorityScheduler _highest = new(ThreadPriority.Highest, 2);
private readonly PriorityScheduler _belowNormal = new(ThreadPriority.BelowNormal, Environment.ProcessorCount * 3);

private readonly SerializeProcessOptions _options = options ?? new(false, false, false, false);

Expand Down Expand Up @@ -84,7 +81,7 @@ public void Dispose()

public async Task<SerializeProcessResults> Serialize(Base root, CancellationToken cancellationToken)
{
var channelTask = Start( cancellationToken);
var channelTask = Start(cancellationToken);
var findTotalObjectsTask = Task.CompletedTask;
if (!_options.SkipFindTotalObjects)
{
Expand Down Expand Up @@ -155,12 +152,18 @@ private async Task<Dictionary<Id, NodeInfo>> Traverse(Base obj, bool isEnd, Canc
if (item.NeedsStorage)
{
//just await enqueuing
await Task.Factory.StartNew(async () =>
{
Interlocked.Increment(ref _objectsSerialized);
await Save(item, cancellationToken).ConfigureAwait(false);
},
cancellationToken, TaskCreationOptions.DenyChildAttach, _highest).ConfigureAwait(true);
await Task
.Factory.StartNew(
async () =>
{
Interlocked.Increment(ref _objectsSerialized);
await Save(item, cancellationToken).ConfigureAwait(false);
},
cancellationToken,
TaskCreationOptions.DenyChildAttach,
_highest
)
.ConfigureAwait(true);
}

if (!currentClosures.ContainsKey(item.Id))
Expand Down
4 changes: 2 additions & 2 deletions tests/Speckle.Sdk.Serialization.Tests/DetachedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public async Task CanSerialize_New_Detached_With_DataChunks()

var objects = new Dictionary<string, string>();

using var process2 = new SerializeProcess(
using var process2 = new SerializeProcess(
null,
new DummySendCacheManager(objects),
new DummyServerObjectManager(),
Expand Down Expand Up @@ -413,7 +413,7 @@ public async Task CanSerialize_New_Detached_With_DataChunks2()

var objects = new Dictionary<string, string>();

using var process2 = new SerializeProcess(
using var process2 = new SerializeProcess(
null,
new DummySendCacheManager(objects),
new DummyServerObjectManager(),
Expand Down

0 comments on commit e1f1ade

Please sign in to comment.