diff --git a/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalInputStream.java b/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalInputStream.java deleted file mode 100644 index 8bcdf44cfb8..00000000000 --- a/plugins/org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/control/impl/TerminalInputStream.java +++ /dev/null @@ -1,334 +0,0 @@ -/******************************************************************************* - * Copyright (c) 1996, 2008 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Michael Scharf (Wind River) - initial API and implementation - * Douglas Lea (Addison Wesley) - [cq:1552] BoundedBufferWithStateTracking adapted to BoundedByteBuffer - *******************************************************************************/ - -package org.eclipse.tm.internal.terminal.control.impl; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Timer; -import java.util.TimerTask; - -import org.eclipse.swt.widgets.Display; - -/** - * The main purpose of this class is to start a runnable in the - * display thread when data is available and to pretend no data - * is available after a given amount of time the runnable is running. - * - */ -public class TerminalInputStream extends InputStream { - /** - * The maximum time in milliseconds the {@link #fNotifyChange} runs until - * {@link #ready()} returns false. - */ - private final int fUITimeout; - /** - * The output stream used by the terminal backend to write to the terminal - */ - protected final OutputStream fOutputStream; - /** - * This runnable is called every time some characters are available from... - */ - private final Runnable fNotifyChange; - /** - * A shared timer for all terminals. This times is used to limit the - * time used in the display thread.... - */ - static Timer fgTimer=new Timer(false); - /** - * A blocking byte queue. - */ - private final BoundedByteBuffer fQueue; - - /** - * The maximum amount of data read and written in one shot. - * The timer cannot interrupt reading this amount of data. - * {@link #available()} and {@link #read(byte[], int, int)} - * This is used as optimization, because reading single characters - * can be very inefficient, because each call is synchronized. - */ - // block size must be smaller than the Queue capacity! - final int BLOCK_SIZE=64; - - - /** - * The runnable that is scheduled in the display tread. Takes care of the - * timeout management. It calls the {@link #fNotifyChange} - */ - // synchronized with fQueue! - private Runnable fRunnable; - - /** - * Used as flag to indicate that the current runnable - * has used enough time in the display thread. - * This variable is set by a timer thread after the - * Runnable starts to run in the Display thread after - * {@link #fUITimeout}. - */ - // synchronized with fQueue! - private boolean fEnoughDisplayTime; - - /** - * A byte bounded buffer used to synchronize the input and the output stream. - *
- * Adapted from BoundedBufferWithStateTracking - * http://gee.cs.oswego.edu/dl/cpj/allcode.java - * http://gee.cs.oswego.edu/dl/cpj/ - *
- * BoundedBufferWithStateTracking is part of the examples for the book - * Concurrent Programming in Java: Design Principles and Patterns by - * Doug Lea (ISBN 0-201-31009-0). Second edition published by - * Addison-Wesley, November 1999. The code is - * Copyright(c) Douglas Lea 1996, 1999 and released to the public domain - * and may be used for any purposes whatsoever. - *
- * For some reasons a solution based on - * PipedOutputStream/PipedIntputStream - * does work *very* slowly: - * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4404700 - *
- *
- */
- class BoundedByteBuffer {
- protected final byte[] fBuffer; // the elements
- protected int fPutPos = 0; // circular indices
- protected int fTakePos = 0;
- protected int fUsedSlots = 0; // the count
- public BoundedByteBuffer(int capacity) throws IllegalArgumentException {
- // make sure we don't deadlock on too small capacity
- if(capacity
- */
- public void close() throws IOException {
- }
-
- public int read(byte[] cbuf, int off, int len) throws IOException {
- int n=0;
- // read as much as we can using a single synchronized statement
- synchronized (fQueue) {
- try {
- // The assumption is that the caller has used available to
- // check if bytes are available! That's why we don't check
- // for fEnoughDisplayTime!
- // Make sure that not more than BLOCK_SIZE is read in one call
- while(fQueue.size()>0 && n