-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskFactoryConfig.cs
More file actions
38 lines (34 loc) · 1.33 KB
/
Copy pathTaskFactoryConfig.cs
File metadata and controls
38 lines (34 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Threading;
using System.Threading.Tasks;
using Gilzoide.TaskFactoryObject.TaskSchedulers;
using UnityEngine;
namespace Gilzoide.TaskFactoryObject
{
[Serializable]
public class TaskFactoryConfig
{
[Min(0)] public int MaximumConcurrency = 0;
public TaskSchedulerType SchedulerType;
public TaskCreationOptions DefaultTaskCreationOptions = TaskCreationOptions.None;
public TaskContinuationOptions DefaultTaskContinuationOptions = TaskContinuationOptions.None;
public ThreadOptions OwnThreadsOptions;
public TaskScheduler CreateScheduler(CancellationToken cancellationToken = default)
{
return TaskSchedulerFactory.Create(SchedulerType, MaximumConcurrency, cancellationToken, OwnThreadsOptions);
}
public TaskFactory CreateFactory(TaskScheduler taskScheduler, CancellationToken cancellationToken = default)
{
return new TaskFactory(
cancellationToken,
DefaultTaskCreationOptions,
DefaultTaskContinuationOptions,
taskScheduler
);
}
public TaskFactory CreateFactory(CancellationToken cancellationToken = default)
{
return CreateFactory(CreateScheduler(cancellationToken), cancellationToken);
}
}
}