⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aesemaphore.java

📁 java 文件下载器。可自定义
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   AESemaphore.java

package org.gudy.azureus2.core3.util;


// Referenced classes of package org.gudy.azureus2.core3.util:
//			AEMonSem, Debug

public class AESemaphore extends AEMonSem
{

	private int dont_wait;
	private int total_reserve;
	private int total_release;
	private boolean released_forever;
	protected Thread latest_waiter;

	public AESemaphore(String _name)
	{
		this(_name, 0);
	}

	public AESemaphore(String _name, int count)
	{
		super(_name, false);
		dont_wait = 0;
		total_reserve = 0;
		total_release = 0;
		released_forever = false;
		dont_wait = count;
		total_release = count;
	}

	public void reserve()
	{
		if (!reserve(0L))
			Debug.out((new StringBuilder()).append("AESemaphore: reserve completed without acquire [").append(getString()).append("]").toString());
	}

	public boolean reserve(long millis)
	{
		return reserveSupport(millis, 1) == 1;
	}

	public boolean reserveIfAvailable()
	{
		AESemaphore aesemaphore = this;
		JVM INSTR monitorenter ;
		if (!released_forever && dont_wait <= 0)
			break MISSING_BLOCK_LABEL_26;
		reserve();
		return true;
		false;
		aesemaphore;
		JVM INSTR monitorexit ;
		return;
		Exception exception;
		exception;
		throw exception;
	}

	public int reserveSet(int max_to_reserve, long millis)
	{
		return reserveSupport(millis, max_to_reserve);
	}

	public int reserveSet(int max_to_reserve)
	{
		return reserveSupport(0L, max_to_reserve);
	}

	protected int reserveSupport(long millis, int max_to_reserve)
	{
		if (DEBUG)
			super.debugEntry();
		AESemaphore aesemaphore = this;
		JVM INSTR monitorenter ;
		entry_count++;
		if (released_forever)
			return 1;
		if (dont_wait != 0)
			break MISSING_BLOCK_LABEL_225;
		int num_to_get;
label0:
		{
			waiting++;
			latest_waiter = Thread.currentThread();
			if (waiting <= 1);
			if (millis == 0L)
			{
				int spurious_count = 0;
				do
				{
					wait();
					if (total_reserve != total_release)
						break label0;
				} while (++spurious_count <= 1024);
				Debug.out("AESemaphore: spurious wakeup limit exceeded");
				throw new Throwable("die die die");
			}
			wait(millis);
		}
		if (total_reserve != total_release)
			break MISSING_BLOCK_LABEL_162;
		waiting--;
		num_to_get = 0;
		latest_waiter = null;
		aesemaphore;
		JVM INSTR monitorexit ;
		return num_to_get;
		Exception exception;
		try
		{
			total_reserve++;
			num_to_get = 1;
		}
		catch (Throwable e)
		{
			waiting--;
			Debug.out("**** semaphore operation interrupted ****");
			throw new RuntimeException("Semaphore: operation interrupted", e);
		}
		finally
		{
			latest_waiter = null;
		}
		latest_waiter = null;
		aesemaphore;
		JVM INSTR monitorexit ;
		return num_to_get;
		e = max_to_reserve <= dont_wait ? ((Throwable) (max_to_reserve)) : ((Throwable) (dont_wait));
		dont_wait -= e;
		total_reserve += e;
		e;
		aesemaphore;
		JVM INSTR monitorexit ;
		return;
		Exception exception1;
		exception1;
		throw exception1;
	}

	public void release()
	{
		synchronized (this)
		{
			total_release++;
			if (waiting != 0)
			{
				waiting--;
				notify();
			} else
			{
				dont_wait++;
			}
		}
		if (DEBUG)
			debugExit();
		break MISSING_BLOCK_LABEL_84;
		Exception exception1;
		exception1;
		if (DEBUG)
			debugExit();
		throw exception1;
	}

	public void releaseAllWaiters()
	{
		synchronized (this)
		{
			int x = waiting;
			for (int i = 0; i < x; i++)
				release();

		}
	}

	public void releaseForever()
	{
		synchronized (this)
		{
			releaseAllWaiters();
			released_forever = true;
		}
	}

	public boolean isReleasedForever()
	{
		AESemaphore aesemaphore = this;
		JVM INSTR monitorenter ;
		return released_forever;
		Exception exception;
		exception;
		throw exception;
	}

	public int getValue()
	{
		AESemaphore aesemaphore = this;
		JVM INSTR monitorenter ;
		return dont_wait - waiting;
		Exception exception;
		exception;
		throw exception;
	}

	public String getString()
	{
		AESemaphore aesemaphore = this;
		JVM INSTR monitorenter ;
		return (new StringBuilder()).append("value=").append(dont_wait).append(",waiting=").append(waiting).append(",res=").append(total_reserve).append(",rel=").append(total_release).toString();
		Exception exception;
		exception;
		throw exception;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -