public PooledValueTaskSource()
 {
     this.innerSource = new ManualResetValueTaskSourceCore <T>
     {
         RunContinuationsAsynchronously = true
     };
 }
Exemplo n.º 2
0
 public MyScheduler(int ms)
 {
     _ms    = ms;
     _start = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
     _manualResetValueTaskSourceCore = new ManualResetValueTaskSourceCore <bool>();
     _manualResetValueTaskSourceCore.RunContinuationsAsynchronously = true;
 }
Exemplo n.º 3
0
 public StreamTaskSource()
 {
     _manualResetValueTaskSource = new ManualResetValueTaskSourceCore <T>
     {
         RunContinuationsAsynchronously = false
     };
 }
 public DefaultObjectPipeWithSupplyControl()
     : base()
 {
     _taskSourceCore = new ManualResetValueTaskSourceCore<bool>
     {
         RunContinuationsAsynchronously = true
     };
 }
Exemplo n.º 5
0
 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();
 }
Exemplo n.º 6
0
        public ValueTaskSource(CancellationToken token = default)
        {
            this.token = token;

            core   = new ManualResetValueTaskSourceCore <T>();
            source = new ValueTaskSourceInternal(this);
            cancellationTokenRegistration = token.Register(Cancel);
            syncObj = new object();
        }
Exemplo n.º 7
0
 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;
        }
Exemplo n.º 10
0
        // 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);
        }
Exemplo n.º 11
0
 public DefaultObjectPipe()
 {
     SetBufferSegment(CreateSegment());
     _taskSourceCore = new ManualResetValueTaskSourceCore <T>();
 }
Exemplo n.º 12
0
 /// <summary>
 /// ManualResetValueTaskSource
 /// </summary>
 public ManualResetValueTaskSource()
 {
     _core = new ManualResetValueTaskSourceCore <T>();
 }
Exemplo n.º 13
0
 public DefaultObjectPipeWithSupplyControl()
     : base()
 {
     _taskSourceCore = new ManualResetValueTaskSourceCore <bool>();
 }
Exemplo n.º 14
0
 public ValueTaskSource(ManualResetValueTaskSourceCore <int> val)
 {
     Val = val;
 }