This file contains hidden or 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
using System.Collections.Concurrent; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace Commons { | |
public static class BlockingCollectionExtensions { | |
public static async Task<bool> WaitToReadAsync<T>(this BlockingCollection<T> source, CancellationToken cancellationToken) { | |
cancellationToken.ThrowIfCancellationRequested(); |
This file contains hidden or 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
namespace System.Diagnostics.CodeAnalysis { | |
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)] | |
internal sealed class MaybeNullAttribute : Attribute { | |
} | |
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] | |
internal sealed class AllowNullAttribute : Attribute { | |
} | |
} |
This file contains hidden or 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
using System; | |
namespace Commons { | |
/// <summary> | |
/// スレッド セーフなアキュムレータ。 | |
/// </summary> | |
/// <typeparam name="T">アキュムレータが扱うデータ型。</typeparam> | |
public class ConcurrentAccumulator<T> { | |
private readonly object _lockObj = new object(); |
This file contains hidden or 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
namespace Commons { | |
/// <summary> | |
/// https://github.com/dotnet/csharplang/issues/803#issuecomment-471575318 | |
/// </summary> | |
public readonly struct ObjectIniter<T> { | |
public ObjectIniter(T obj) { | |
Obj = obj; | |
} |
This file contains hidden or 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
#nullable enable | |
using System; | |
using System.Collections; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Reflection; | |
namespace Inasync { |
This file contains hidden or 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
using System; | |
using System.Collections.Concurrent; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace Inasync { | |
public static class BlockingCollectionExtensions { | |
public static void Post<TMessage>(this BlockingCollection<TMessage> channel, TMessage message) { |
This file contains hidden or 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
using System; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Extensions.DependencyInjection; | |
namespace Inasync.Hosting { | |
public interface IRequestHandler { |
This file contains hidden or 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
using System; | |
using Newtonsoft.Json; | |
namespace Commons { | |
public sealed class RemoveTrailingZerosConverter : JsonConverter { | |
public static readonly RemoveTrailingZerosConverter Default = new RemoveTrailingZerosConverter(); | |
public override bool CanConvert(Type objectType) { | |
return objectType == typeof(decimal); |
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.Hosting; | |
using Microsoft.Extensions.Logging; | |
namespace Commons { |
This file contains hidden or 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
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Hosting; | |
using Microsoft.Extensions.Logging; | |
namespace Inasync.Hosting { | |
public delegate Task CommandDelegate(string[] args, CancellationToken cancellationToken); |