ThreadPoolWorkItemFactory
Represents factory of thread pool work items.
using System;
using System.Runtime.CompilerServices;
using System.Threading;
namespace DotNext.Threading
{
[NullableContext(1)]
[Nullable(0)]
[CLSCompliant(false)]
public static class ThreadPoolWorkItemFactory
{
private sealed class ThreadPoolWorkItem<T> : Tuple<T>, IThreadPoolWorkItem
{
private readonly IntPtr invoker;
internal ThreadPoolWorkItem(IntPtr invoker, T arg)
: base(arg)
{
this.invoker = invoker;
}
void IThreadPoolWorkItem.Execute()
{
IntPtr intPtr = invoker;
;
}
}
private sealed class ThreadPoolWorkItem<T1, T2> : Tuple<T1, T2>, IThreadPoolWorkItem
{
private readonly IntPtr invoker;
internal ThreadPoolWorkItem(IntPtr invoker, T1 arg1, T2 arg2)
: base(arg1, arg2)
{
this.invoker = invoker;
}
void IThreadPoolWorkItem.Execute()
{
IntPtr intPtr = invoker;
;
}
}
private sealed class ThreadPoolWorkItem<T1, T2, T3> : Tuple<T1, T2, T3>, IThreadPoolWorkItem
{
private readonly IntPtr invoker;
internal ThreadPoolWorkItem(IntPtr invoker, T1 arg1, T2 arg2, T3 arg3)
: base(arg1, arg2, arg3)
{
this.invoker = invoker;
}
void IThreadPoolWorkItem.Execute()
{
IntPtr intPtr = invoker;
;
}
}
public unsafe static IThreadPoolWorkItem Create<[Nullable(2)] T>([Nullable(new byte[] {
0,
1
})] IntPtr workItem, T arg)
{
if (workItem == (IntPtr)(void*)null)
throw new ArgumentNullException("workItem");
return new ThreadPoolWorkItem<T>(workItem, arg);
}
public unsafe static IThreadPoolWorkItem Create<[Nullable(2)] T1, [Nullable(2)] T2>([Nullable(new byte[] {
0,
1,
1
})] IntPtr workItem, T1 arg1, T2 arg2)
{
if (workItem == (IntPtr)(void*)null)
throw new ArgumentNullException("workItem");
return new ThreadPoolWorkItem<T1, T2>(workItem, arg1, arg2);
}
public unsafe static IThreadPoolWorkItem Create<[Nullable(2)] T1, [Nullable(2)] T2, [Nullable(2)] T3>([Nullable(new byte[] {
0,
1,
1,
1
})] IntPtr workItem, T1 arg1, T2 arg2, T3 arg3)
{
if (workItem == (IntPtr)(void*)null)
throw new ArgumentNullException("workItem");
return new ThreadPoolWorkItem<T1, T2, T3>(workItem, arg1, arg2, arg3);
}
}
}