当前位置: 首页>>代码示例>>Java>>正文


Java ChannelCondition.EXIT_SIGNAL属性代码示例

本文整理汇总了Java中com.trilead.ssh2.ChannelCondition.EXIT_SIGNAL属性的典型用法代码示例。如果您正苦于以下问题:Java ChannelCondition.EXIT_SIGNAL属性的具体用法?Java ChannelCondition.EXIT_SIGNAL怎么用?Java ChannelCondition.EXIT_SIGNAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.trilead.ssh2.ChannelCondition的用法示例。


在下文中一共展示了ChannelCondition.EXIT_SIGNAL属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: waitForCondition

/**
 * Wait until for a condition.
 * 
 * @param c
 *            Channel
 * @param timeout
 *            in ms, 0 means no timeout.
 * @param condition_mask
 *            minimum event mask
 * @return all current events
 * 
 */
public int waitForCondition(Channel c, long timeout, int condition_mask)
{
	long end_time = 0;
	boolean end_time_set = false;

	synchronized (c)
	{
		while (true)
		{
			int current_cond = 0;

			int stdoutAvail = c.stdoutWritepos - c.stdoutReadpos;
			int stderrAvail = c.stderrWritepos - c.stderrReadpos;

			if (stdoutAvail > 0)
				current_cond = current_cond | ChannelCondition.STDOUT_DATA;

			if (stderrAvail > 0)
				current_cond = current_cond | ChannelCondition.STDERR_DATA;

			if (c.EOF)
				current_cond = current_cond | ChannelCondition.EOF;

			if (c.getExitStatus() != null)
				current_cond = current_cond | ChannelCondition.EXIT_STATUS;

			if (c.getExitSignal() != null)
				current_cond = current_cond | ChannelCondition.EXIT_SIGNAL;

			if (c.state == Channel.STATE_CLOSED)
				return current_cond | ChannelCondition.CLOSED | ChannelCondition.EOF;

			if ((current_cond & condition_mask) != 0)
				return current_cond;

			if (timeout > 0)
			{
				if (!end_time_set)
				{
					end_time = System.currentTimeMillis() + timeout;
					end_time_set = true;
				}
				else
				{
					timeout = end_time - System.currentTimeMillis();

					if (timeout <= 0)
						return current_cond | ChannelCondition.TIMEOUT;
				}
			}

			try
			{
				if (timeout > 0)
					c.wait(timeout);
				else
					c.wait();
			}
			catch (InterruptedException e)
			{
			}
		}
	}
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:76,代码来源:ChannelManager.java

示例2: waitForCondition

/**
 * Wait until for a condition.
 * 
 * @param c
 *            Channel
 * @param timeout
 *            in ms, 0 means no timeout.
 * @param condition_mask
 *            minimum event mask
 * @return all current events
 * 
 */
public int waitForCondition(Channel c, long timeout, int condition_mask) {
	long end_time = 0;
	boolean end_time_set = false;

	synchronized (c) {
		while (true) {
			int current_cond = 0;

			int stdoutAvail = c.stdoutWritepos - c.stdoutReadpos;
			int stderrAvail = c.stderrWritepos - c.stderrReadpos;

			if (stdoutAvail > 0)
				current_cond = current_cond | ChannelCondition.STDOUT_DATA;

			if (stderrAvail > 0)
				current_cond = current_cond | ChannelCondition.STDERR_DATA;

			if (c.EOF)
				current_cond = current_cond | ChannelCondition.EOF;

			if (c.getExitStatus() != null)
				current_cond = current_cond | ChannelCondition.EXIT_STATUS;

			if (c.getExitSignal() != null)
				current_cond = current_cond | ChannelCondition.EXIT_SIGNAL;

			if (c.state == Channel.STATE_CLOSED)
				return current_cond | ChannelCondition.CLOSED
						| ChannelCondition.EOF;

			if ((current_cond & condition_mask) != 0)
				return current_cond;

			if (timeout > 0) {
				if (!end_time_set) {
					end_time = System.currentTimeMillis() + timeout;
					end_time_set = true;
				} else {
					timeout = end_time - System.currentTimeMillis();

					if (timeout <= 0)
						return current_cond | ChannelCondition.TIMEOUT;
				}
			}

			try {
				if (timeout > 0)
					c.wait(timeout);
				else
					c.wait();
			} catch (InterruptedException e) {
			}
		}
	}
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:67,代码来源:ChannelManager.java


注:本文中的com.trilead.ssh2.ChannelCondition.EXIT_SIGNAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。