Example #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;
            }
        }
Example #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();
        }
Example #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());
 }
Example #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;
        }
Example #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;
        }
Example #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();
        }
Example #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());
 }
Example #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;
            }
        }