public PooledValueTaskSource()
 {
     this.innerSource = new ManualResetValueTaskSourceCore <T>
     {
         RunContinuationsAsynchronously = true
     };
 }
Esempio n. 2
0
 public MyScheduler(int ms)
 {
     _ms    = ms;
     _start = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
     _manualResetValueTaskSourceCore = new ManualResetValueTaskSourceCore <bool>();
     _manualResetValueTaskSourceCore.RunContinuationsAsynchronously = true;
 }
Esempio n. 3
0
 public StreamTaskSource()
 {
     _manualResetValueTaskSource = new ManualResetValueTaskSourceCore <T>
     {
         RunContinuationsAsynchronously = false
     };
 }
 public DefaultObjectPipeWithSupplyControl()
     : base()
 {
     _taskSourceCore = new ManualResetValueTaskSourceCore<bool>
     {
         RunContinuationsAsynchronously = true
     };
 }
Esempio 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();
 }
Esempio 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();
        }
Esempio 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;
        }
Esempio 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);
        }
Esempio n. 11
0
 public DefaultObjectPipe()
 {
     SetBufferSegment(CreateSegment());
     _taskSourceCore = new ManualResetValueTaskSourceCore <T>();
 }
Esempio n. 12
0
 /// <summary>
 /// ManualResetValueTaskSource
 /// </summary>
 public ManualResetValueTaskSource()
 {
     _core = new ManualResetValueTaskSourceCore <T>();
 }
Esempio n. 13
0
 public DefaultObjectPipeWithSupplyControl()
     : base()
 {
     _taskSourceCore = new ManualResetValueTaskSourceCore <bool>();
 }
Esempio n. 14
0
 public ValueTaskSource(ManualResetValueTaskSourceCore <int> val)
 {
     Val = val;
 }