public virtual void SetUp() { @out = new PipedOutputStream(); @in = new PipedInputStream(@out); timer = new InterruptTimer(); @is = new TimeoutInputStream(@in, timer); @is.SetTimeout(timeout); }
public void TestBigWrite () { PipedInputStream pin = new PipedInputStream (); PipedOutputStream pout = new PipedOutputStream (pin); Random r = new Random (0); byte[] data = new byte [PipedInputStream.PIPE_SIZE * 3]; r.NextBytes (data); ThreadPool.QueueUserWorkItem (delegate { pout.Write (data); pout.Close (); }); int n = 0; byte[] buffer = new byte [100]; int nr; while ((nr = pin.Read (buffer)) != -1) { for (int i=0; i < nr; i++) Assert.AreEqual (buffer[i], data[n++], "Position " + n); } }
public PipedOutputStream (PipedInputStream iss) : this() { Attach (iss); }
public _Thread_365(InternalLocalPushConnection _enclosing, Repository dst, PipedInputStream out_r, PipedOutputStream in_w, string baseArg1) : base(baseArg1) { this._enclosing = _enclosing; this.dst = dst; this.out_r = out_r; this.in_w = in_w; }
/// <exception cref="NGit.Errors.TransportException"></exception> public InternalLocalPushConnection(TransportLocal _enclosing) : base(_enclosing) { this._enclosing = _enclosing; Repository dst; try { dst = new FileRepository(this._enclosing.remoteGitDir); } catch (IOException) { throw new TransportException(this.uri, JGitText.Get().notAGitDirectory); } PipedInputStream in_r; PipedOutputStream in_w; PipedInputStream out_r; PipedOutputStream out_w; try { in_r = new PipedInputStream(); in_w = new PipedOutputStream(in_r); out_r = new PipedInputStream(); out_w = new PipedOutputStream(out_r); } catch (IOException err) { dst.Close(); throw new TransportException(this.uri, JGitText.Get().cannotConnectPipes, err); } this.worker = new _Thread_365(this, dst, out_r, in_w, "JGit-Receive-Pack"); // Client side of the pipes should report the problem. // Clients side will notice we went away, and report. // Ignore close failure, we probably crashed above. // Ignore close failure, we probably crashed above. this.worker.Start(); this.Init(in_r, out_w); this.ReadAdvertisedRefs(); }
/// <exception cref="NGit.Errors.TransportException"></exception> public InternalLocalFetchConnection(TransportLocal _enclosing) : base(_enclosing) { this._enclosing = _enclosing; Repository dst; try { dst = new FileRepository(this._enclosing.remoteGitDir); } catch (IOException) { throw new TransportException(this.uri, JGitText.Get().notAGitDirectory); } PipedInputStream in_r; PipedOutputStream in_w; PipedInputStream out_r; PipedOutputStream out_w; try { in_r = new PipedInputStream(); in_w = new PipedOutputStream(in_r); out_r = new _PipedInputStream_218(); // The client (BasePackFetchConnection) can write // a huge burst before it reads again. We need to // force the buffer to be big enough, otherwise it // will deadlock both threads. out_w = new PipedOutputStream(out_r); } catch (IOException err) { dst.Close(); throw new TransportException(this.uri, JGitText.Get().cannotConnectPipes, err); } this.worker = new _Thread_233(this, dst, out_r, in_w, "JGit-Upload-Pack"); // Client side of the pipes should report the problem. // Clients side will notice we went away, and report. // Ignore close failure, we probably crashed above. // Ignore close failure, we probably crashed above. this.worker.Start(); this.Init(in_r, out_w); this.ReadAdvertisedRefs(); }
public ConsoleTextArea(string[] argv) : base() { history = new List<string>(); console1 = new ConsoleWriter(this); console2 = new ConsoleWriter(this); @out = new TextWriter(console1, true); err = new TextWriter(console2, true); PipedOutputStream outPipe = new PipedOutputStream(); inPipe = new PrintWriter(outPipe); @in = new PipedInputStream(); try { outPipe.Connect(@in); } catch (IOException exc) { Sharpen.Runtime.PrintStackTrace(exc); } GetDocument().AddDocumentListener(this); AddKeyListener(this); SetLineWrap(true); SetFont(new Font("Monospaced", 0, 12)); }
internal void Attach(PipedInputStream iss) { ips = iss; }
/// <exception cref="System.IO.IOException"></exception> private void SetupStreams() { this.inputStream = this.channel.GetInputStream(); // JSch won't let us interrupt writes when we use our InterruptTimer // to break out of a long-running write operation. To work around // that we spawn a background thread to shuttle data through a pipe, // as we can issue an interrupted write out of that. Its slower, so // we only use this route if there is a timeout. OutputStream @out = this.channel.GetOutputStream(); if (this.timeout <= 0) { this.outputStream = @out; } else { PipedInputStream pipeIn = new PipedInputStream(); StreamCopyThread copier = new StreamCopyThread(pipeIn, @out); PipedOutputStream pipeOut = new _PipedOutputStream_173(this, copier, pipeIn); // Just wake early, the thread will terminate // anyway. copier.Start(); this.outputStream = pipeOut; } this.errStream = this.channel.GetErrStream(); }
public _PipedOutputStream_250(JschConnection _enclosing, StreamCopyThread copier, PipedInputStream baseArg1) : base(baseArg1) { this._enclosing = _enclosing; this.copier = copier; }
/// <exception cref="System.IO.IOException"></exception> internal override OutputStream GetOutputStream() { // JSch won't let us interrupt writes when we use our InterruptTimer // to break out of a long-running write operation. To work around // that we spawn a background thread to shuttle data through a pipe, // as we can issue an interrupted write out of that. Its slower, so // we only use this route if there is a timeout. // OutputStream @out = this.channel.GetOutputStream(); if (this._enclosing.GetTimeout() <= 0) { return @out; } PipedInputStream pipeIn = new PipedInputStream(); StreamCopyThread copier = new StreamCopyThread(pipeIn, @out); PipedOutputStream pipeOut = new _PipedOutputStream_250(this, copier, pipeIn); // Just wake early, the thread will terminate anyway. copier.Start(); return pipeOut; }
/// <exception cref="System.IO.IOException"></exception> public PassiveOutputStream(Channel _enclosing, PipedInputStream @in) : base(@in) { this._enclosing = _enclosing; }
public _PipedOutputStream_173(JschProcess _enclosing, StreamCopyThread copier, PipedInputStream baseArg1) : base(baseArg1) { this._enclosing = _enclosing; this.copier = copier; }
public void Attach (PipedInputStream iss) { ips = iss; }
public PipedOutputStream(PipedInputStream iss) : this() { Attach(iss); }
public void Attach(PipedInputStream iss) { ips = iss; }