Esempio n. 1
0
        private async Task CloseInternal()
        {
            lock (this)
            {
                List <Buffer> remaining = writes.Shutdown();
                if (remaining.Count > 0)
                {
                    throw new ApplicationException("Got end write buffer with buffers still in the queue");
                }
                writes = null;
            }

            log.LogInformation("Closing write stream");

            try
            {
                error = await Close();

                if (error != null)
                {
                    errorType = ErrorType.Close;
                }
            }
            catch (Exception e)
            {
                log.LogError("Got exception closing stream " + e.ToString());
                error     = e.ToString();
                errorType = ErrorType.Close;
            }
        }
Esempio n. 2
0
        private async Task Worker()
        {
            bool errorState = false;

            try
            {
                await Open();
            }
            catch (Exception e)
            {
                SendError(e, ErrorType.Open);
                errorState = true;
            }
            await DataLoop(errorState);

            List <Buffer> discard;

            lock (this)
            {
                discard     = queue.Shutdown();
                interrupted = true;
                queue       = null;
            }

            foreach (var buffer in discard.Where(b => b != null))
            {
                client.DiscardBuffer(buffer);
            }

            await OnFinishedRead();
        }
Esempio n. 3
0
 public void Start()
 {
     length      = -1;
     offset      = 0;
     interrupted = false;
     queue       = new BufferQueue();
     log.LogInformation("Starting read for " + Source.AbsoluteUri);
     finished = Task.Run(async() => await Worker());
 }
Esempio n. 4
0
        public StreamWriter(IWriterClient c, IDrLogging l)
        {
            client = c;
            log    = new DryadLogger(l);

            writes = new BufferQueue();
            offset = 0;

            finished = new Task(() => { });

            error     = null;
            errorType = ErrorType.IO;
        }
Esempio n. 5
0
        public StreamWriter(IWriterClient c, IDrLogging l)
        {
            client = c;
            log = new DryadLogger(l);

            writes = new BufferQueue();
            offset = 0;

            finished = new Task(() => { });

            error = null;
            errorType = ErrorType.IO;
        }
Esempio n. 6
0
        private async Task Worker()
        {
            bool errorState = false;

            try
            {
                await Open();
            }
            catch (Exception e)
            {
                SendError(e, ErrorType.Open);
                errorState = true;
            }
            await DataLoop(errorState);

            List<Buffer> discard;
            lock (this)
            {
                discard = queue.Shutdown();
                interrupted = true;
                queue = null;
            }

            foreach (var buffer in discard.Where(b => b != null))
            {
                client.DiscardBuffer(buffer);
            }

            await OnFinishedRead();
        }
Esempio n. 7
0
 public void Start()
 {
     length = -1;
     offset = 0;
     interrupted = false;
     queue = new BufferQueue();
     log.LogInformation("Starting read for " + Source.AbsoluteUri);
     finished = Task.Run(async () => await Worker());
 }
Esempio n. 8
0
        private async Task CloseInternal()
        {
            lock (this)
            {
                List<Buffer> remaining = writes.Shutdown();
                if (remaining.Count > 0)
                {
                    throw new ApplicationException("Got end write buffer with buffers still in the queue");
                }
                writes = null;
            }

            log.LogInformation("Closing write stream");

            try
            {
                error = await Close();
                if (error != null)
                {
                    errorType = ErrorType.Close;
                }
            }
            catch (Exception e)
            {
                log.LogError("Got exception closing stream " + e.ToString());
                error = e.ToString();
                errorType = ErrorType.Close;
            }
        }