ファイル分割。Post

This commit is contained in:
ousttrue
2021-02-19 16:09:36 +09:00
parent 282a81e894
commit fa712fc1d4
5 changed files with 94 additions and 60 deletions

View File

@@ -0,0 +1,12 @@
namespace System.Runtime.CompilerServices
{
public sealed class AsyncMethodBuilderAttribute : Attribute
{
public AsyncMethodBuilderAttribute(Type builderType)
{
BuilderType = builderType;
}
public Type BuilderType { get; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 010eb0dc48af5e645af2ff8cb7f7d1d8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -4,18 +4,6 @@ using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace System.Runtime.CompilerServices
{
public sealed class AsyncMethodBuilderAttribute : Attribute
{
public AsyncMethodBuilderAttribute(Type builderType)
{
BuilderType = builderType;
}
public Type BuilderType { get; }
}
}
namespace UniGLTF.AltTask
{
@@ -30,54 +18,6 @@ namespace UniGLTF.AltTask
IAwaiter<T> GetAwaiter();
}
public class TaskQueue : SynchronizationContext, IDisposable
{
[ThreadStatic]
static TaskQueue s_queue;
public new static SynchronizationContext Current
{
get
{
if (s_queue == null)
{
return System.Threading.SynchronizationContext.Current;
}
else
{
return s_queue;
}
}
}
Queue<Action> m_tasks = new Queue<Action>();
public static TaskQueue Create()
{
return new TaskQueue();
}
TaskQueue()
{
s_queue = this;
}
public void Dispose()
{
s_queue = null;
}
public bool ExecuteOneCallback()
{
if (m_tasks.Count == 0)
{
return false;
}
var task = m_tasks.Dequeue();
task();
return true;
}
}
public struct ExplicitTaskMethodBuilder<T>
{

View File

@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Threading;
namespace UniGLTF.AltTask
{
public class TaskQueue : SynchronizationContext, IDisposable
{
[ThreadStatic]
static TaskQueue s_queue;
public new static SynchronizationContext Current
{
get
{
if (s_queue == null)
{
return System.Threading.SynchronizationContext.Current;
}
else
{
return s_queue;
}
}
}
public override void Post(SendOrPostCallback d, object state)
{
m_tasks.Enqueue(() => d(state));
}
Queue<Action> m_tasks = new Queue<Action>();
public static TaskQueue Create()
{
return new TaskQueue();
}
TaskQueue()
{
s_queue = this;
}
public void Dispose()
{
s_queue = null;
}
public bool ExecuteOneCallback()
{
if (m_tasks.Count == 0)
{
return false;
}
var task = m_tasks.Dequeue();
task();
return true;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6a65e00e71613c24e865e35173c30be0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: