public PooledValueTaskSource() { this.innerSource = new ManualResetValueTaskSourceCore <T> { RunContinuationsAsynchronously = true }; }
public MyScheduler(int ms) { _ms = ms; _start = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000; _manualResetValueTaskSourceCore = new ManualResetValueTaskSourceCore <bool>(); _manualResetValueTaskSourceCore.RunContinuationsAsynchronously = true; }
public StreamTaskSource() { _manualResetValueTaskSource = new ManualResetValueTaskSourceCore <T> { RunContinuationsAsynchronously = false }; }
public DefaultObjectPipeWithSupplyControl() : base() { _taskSourceCore = new ManualResetValueTaskSourceCore<bool> { RunContinuationsAsynchronously = true }; }
protected PipeChannel(IPipelineFilter <TPackageInfo> pipelineFilter, ChannelOptions options) { _pipelineFilter = pipelineFilter; _packageTaskSource = new ManualResetValueTaskSourceCore <TPackageInfo>(); Options = options; Logger = options.Logger; Out = options.Out ?? new Pipe(); In = options.In ?? new Pipe(); }
public ValueTaskSource(CancellationToken token = default) { this.token = token; core = new ManualResetValueTaskSourceCore <T>(); source = new ValueTaskSourceInternal(this); cancellationTokenRegistration = token.Register(Cancel); syncObj = new object(); }
public ValueTaskSource(bool runContinuationsAsynchronously = true) { _state = State.None; _valueTaskSource = new ManualResetValueTaskSourceCore <bool>() { RunContinuationsAsynchronously = runContinuationsAsynchronously }; _cancellationRegistration = default; _keepAlive = default; }
public ResettableValueTaskSource(bool runContinuationsAsynchronously = true) { _state = State.None; _valueTaskSource = new ManualResetValueTaskSourceCore <bool>() { RunContinuationsAsynchronously = runContinuationsAsynchronously }; _cancellationRegistration = default; _keepAlive = default; // TODO: defer instantiation only after Task is retrieved _finalTaskSource = new TaskCompletionSource(runContinuationsAsynchronously ? TaskCreationOptions.RunContinuationsAsynchronously : TaskCreationOptions.None); }
public SocketByteHandler(Socket socket) { m_socket = socket; #if VALUETASKSOURCE m_valueTaskSource = new ManualResetValueTaskSourceCore <int> { RunContinuationsAsynchronously = true }; m_socketEventArgs = new SocketAsyncEventArgs(); m_socketEventArgs.Completed += (s, e) => PropagateSocketAsyncEventArgsStatus(); #else m_socketAwaitable = new SocketAwaitable(new SocketAsyncEventArgs()); #endif m_closeSocket = socket.Dispose; RemainingTimeout = Constants.InfiniteTimeout; }
// Main reason why value task can't be await multiple time public async ValueTask <int> TestValueTask() { var manualResetValue = new ManualResetValueTaskSourceCore <int>(); manualResetValue.SetResult(10); var valueTaskSource = new ValueTaskSource(manualResetValue); var valueTask = await new ValueTask <int>(valueTaskSource, 0); // valuetasksource doesn't has to be reallocated manualResetValue.Reset(); valueTaskSource.Val = manualResetValue; manualResetValue.SetResult(20); // new task with new value // this is why ValueTask can't be await twice, it could work but it also doesn't work var secondValueTask = new ValueTask <int>(valueTaskSource, 1); // for complete and advance usage see this http://tooslowexception.com/implementing-custom-ivaluetasksource-async-without-allocations/ return(await secondValueTask); }
public DefaultObjectPipe() { SetBufferSegment(CreateSegment()); _taskSourceCore = new ManualResetValueTaskSourceCore <T>(); }
/// <summary> /// ManualResetValueTaskSource /// </summary> public ManualResetValueTaskSource() { _core = new ManualResetValueTaskSourceCore <T>(); }
public DefaultObjectPipeWithSupplyControl() : base() { _taskSourceCore = new ManualResetValueTaskSourceCore <bool>(); }
public ValueTaskSource(ManualResetValueTaskSourceCore <int> val) { Val = val; }