| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
| <!-- NewPage -->
|
| <html lang="ru">
|
| <head><meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
|
| <!-- Generated by javadoc (version 1.7.0_75) on Mon Dec 21 12:25:24 MSK 2015 -->
|
| <meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
|
| <title>IgniteSemaphore (Ignite 1.5.0-final-SNAPSHOT)</title>
|
| <meta name="date" content="2015-12-21">
|
| <link rel="stylesheet" type="text/css" href="../../../javadoc.css" title="Style">
|
| <link rel='shortcut icon' href='https://ignite.apache.org/favicon.ico'/> |
| <link type='text/css' rel='stylesheet' href='http://agorbatchev.typepad.com/pub/sh/3_0_83/styles/shCore.css'/> |
| <link type='text/css' rel='stylesheet' href='http://agorbatchev.typepad.com/pub/sh/3_0_83/styles/shThemeDefault.css'/> |
| <script type='text/javascript' src='http://agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shCore.js'></script> |
| <script type='text/javascript' src='http://agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shLegacy.js'></script> |
| <script type='text/javascript' src='http://agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shBrushJava.js'></script> |
| <script type='text/javascript' src='http://agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shBrushPlain.js'></script> |
| <script type='text/javascript' src='http://agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shBrushJScript.js'></script> |
| <script type='text/javascript' src='http://agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shBrushBash.js'></script> |
| <script type='text/javascript' src='http://agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shBrushXml.js'></script> |
| <script type='text/javascript' src='http://agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shBrushScala.js'></script> |
| <script type='text/javascript' src='http://agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shBrushGroovy.js'></script> |
| </head> |
|
|
| <body>
|
| <script type="text/javascript"><!--
|
| if (location.href.indexOf('is-external=true') == -1) {
|
| parent.document.title="IgniteSemaphore (Ignite 1.5.0-final-SNAPSHOT)";
|
| }
|
| //-->
|
| </script>
|
| <noscript>
|
| <div>JavaScript is disabled on your browser.</div>
|
| </noscript>
|
| <!-- ========= START OF TOP NAVBAR ======= -->
|
| <div class="topNav"><a name="navbar_top">
|
| <!-- -->
|
| </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
|
| <!-- -->
|
| </a>
|
| <ul class="navList" title="Navigation">
|
| <li><a href="../../../overview-summary.html">Overview</a></li>
|
| <li><a href="package-summary.html">Package</a></li>
|
| <li class="navBarCell1Rev">Class</li>
|
| <li><a href="class-use/IgniteSemaphore.html">Use</a></li>
|
| <li><a href="package-tree.html">Tree</a></li>
|
| <li><a href="../../../deprecated-list.html">Deprecated</a></li>
|
| <li><a href="../../../index-all.html">Index</a></li>
|
| <li><a href="../../../help-doc.html">Help</a></li>
|
| </ul>
|
| <div class="aboutLanguage"><em>Ignite - In-Memory Data Fabric</em></div>
|
| </div>
|
| <div class="subNav">
|
| <ul class="navList">
|
| <li><a href="../../../org/apache/ignite/IgniteScheduler.html" title="interface in org.apache.ignite"><span class="strong">Prev Class</span></a></li>
|
| <li><a href="../../../org/apache/ignite/IgniteServices.html" title="interface in org.apache.ignite"><span class="strong">Next Class</span></a></li>
|
| </ul>
|
| <ul class="navList">
|
| <li><a href="../../../index.html?org/apache/ignite/IgniteSemaphore.html" target="_top">Frames</a></li>
|
| <li><a href="IgniteSemaphore.html" target="_top">No Frames</a></li>
|
| </ul>
|
| <ul class="navList" id="allclasses_navbar_top">
|
| <li><a href="../../../allclasses-noframe.html">All Classes</a></li>
|
| </ul>
|
| <div>
|
| <script type="text/javascript"><!--
|
| allClassesLink = document.getElementById("allclasses_navbar_top");
|
| if(window==top) {
|
| allClassesLink.style.display = "block";
|
| }
|
| else {
|
| allClassesLink.style.display = "none";
|
| }
|
| //-->
|
| </script>
|
| </div>
|
| <div>
|
| <ul class="subNavList">
|
| <li>Summary: </li>
|
| <li>Nested | </li>
|
| <li>Field | </li>
|
| <li>Constr | </li>
|
| <li><a href="#method_summary">Method</a></li>
|
| </ul>
|
| <ul class="subNavList">
|
| <li>Detail: </li>
|
| <li>Field | </li>
|
| <li>Constr | </li>
|
| <li><a href="#method_detail">Method</a></li>
|
| </ul>
|
| </div>
|
| <a name="skip-navbar_top">
|
| <!-- -->
|
| </a></div>
|
| <!-- ========= END OF TOP NAVBAR ========= -->
|
| <!-- ======== START OF CLASS DATA ======== -->
|
| <div class="header">
|
| <div class="subTitle">org.apache.ignite</div>
|
| <h2 title="Interface IgniteSemaphore" class="title">Interface IgniteSemaphore</h2>
|
| </div>
|
| <div class="contentContainer">
|
| <div class="description">
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <dl>
|
| <dt>All Superinterfaces:</dt>
|
| <dd><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html?is-external=true" title="class or interface in java.lang">AutoCloseable</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</a></dd>
|
| </dl>
|
| <hr>
|
| <br>
|
| <pre>public interface <span class="strong">IgniteSemaphore</span>
|
| extends <a href="http://docs.oracle.com/javase/7/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</a></pre>
|
| <div class="block">This interface provides a rich API for working with distributed semaphore. |
| <p> |
| <h1 class="header">Functionality</h1> |
| Distributed semaphore provides functionality similar to <code>java.util.concurrent.Semaphore</code>. |
| <h1 class="header">Creating Distributed Semaphore</h1> |
| Instance of cache semaphore can be created by calling the following method: |
| <a href="../../../org/apache/ignite/Ignite.html#semaphore(java.lang.String,%20int,%20boolean,%20boolean)"><code>Ignite.semaphore(String, int, boolean, boolean)</code></a>.</div>
|
| </li>
|
| </ul>
|
| </div>
|
| <div class="summary">
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <!-- ========== METHOD SUMMARY =========== -->
|
| <ul class="blockList">
|
| <li class="blockList"><a name="method_summary">
|
| <!-- -->
|
| </a>
|
| <h3>Method Summary</h3>
|
| <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
|
| <caption><span>Methods</span><span class="tabEnd"> </span></caption>
|
| <tr>
|
| <th class="colFirst" scope="col">Modifier and Type</th>
|
| <th class="colLast" scope="col">Method and Description</th>
|
| </tr>
|
| <tr class="altColor">
|
| <td class="colFirst"><code>void</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#acquire()">acquire</a></strong>()</code>
|
| <div class="block">Acquires a permit from this semaphore, blocking until one is available, or the thread is <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupted</a>.</div>
|
| </td>
|
| </tr>
|
| <tr class="rowColor">
|
| <td class="colFirst"><code>void</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#acquire(int)">acquire</a></strong>(int permits)</code>
|
| <div class="block">Acquires the given number of permits from this semaphore, blocking until all are available, or the thread is |
| <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupted</a>.</div>
|
| </td>
|
| </tr>
|
| <tr class="altColor">
|
| <td class="colFirst"><code>void</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#acquireUninterruptibly()">acquireUninterruptibly</a></strong>()</code>
|
| <div class="block">Acquires a permit from this semaphore, blocking until one is available.</div>
|
| </td>
|
| </tr>
|
| <tr class="rowColor">
|
| <td class="colFirst"><code>void</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#acquireUninterruptibly(int)">acquireUninterruptibly</a></strong>(int permits)</code>
|
| <div class="block">Acquires the given number of permits from this semaphore, blocking until all are available.</div>
|
| </td>
|
| </tr>
|
| <tr class="altColor">
|
| <td class="colFirst"><code>int</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#availablePermits()">availablePermits</a></strong>()</code>
|
| <div class="block">Returns the current number of permits available in this semaphore.</div>
|
| </td>
|
| </tr>
|
| <tr class="rowColor">
|
| <td class="colFirst"><code>void</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#close()">close</a></strong>()</code>
|
| <div class="block">Removes this semaphore.</div>
|
| </td>
|
| </tr>
|
| <tr class="altColor">
|
| <td class="colFirst"><code>int</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#drainPermits()">drainPermits</a></strong>()</code>
|
| <div class="block">Acquires and returns all permits that are immediately available.</div>
|
| </td>
|
| </tr>
|
| <tr class="rowColor">
|
| <td class="colFirst"><code>int</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#getQueueLength()">getQueueLength</a></strong>()</code>
|
| <div class="block">Returns an estimate of the number of nodes waiting to acquire.</div>
|
| </td>
|
| </tr>
|
| <tr class="altColor">
|
| <td class="colFirst"><code>boolean</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#hasQueuedThreads()">hasQueuedThreads</a></strong>()</code>
|
| <div class="block">Queries whether any threads are waiting to acquire.</div>
|
| </td>
|
| </tr>
|
| <tr class="rowColor">
|
| <td class="colFirst"><code>boolean</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#isBroken()">isBroken</a></strong>()</code>
|
| <div class="block">Gets <code>broken</code> status of the semaphore.</div>
|
| </td>
|
| </tr>
|
| <tr class="altColor">
|
| <td class="colFirst"><code>boolean</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#isFailoverSafe()">isFailoverSafe</a></strong>()</code>
|
| <div class="block">Returns <code>true</code> if this semaphore is safe to use after node failure.</div>
|
| </td>
|
| </tr>
|
| <tr class="rowColor">
|
| <td class="colFirst"><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#name()">name</a></strong>()</code>
|
| <div class="block">Gets name of the semaphore.</div>
|
| </td>
|
| </tr>
|
| <tr class="altColor">
|
| <td class="colFirst"><code>void</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#release()">release</a></strong>()</code>
|
| <div class="block">Releases a permit, returning it to the semaphore.</div>
|
| </td>
|
| </tr>
|
| <tr class="rowColor">
|
| <td class="colFirst"><code>void</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#release(int)">release</a></strong>(int permits)</code>
|
| <div class="block">Releases the given number of permits, returning them to the semaphore.</div>
|
| </td>
|
| </tr>
|
| <tr class="altColor">
|
| <td class="colFirst"><code>boolean</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#removed()">removed</a></strong>()</code>
|
| <div class="block">Gets <code>removed</code> status of the semaphore.</div>
|
| </td>
|
| </tr>
|
| <tr class="rowColor">
|
| <td class="colFirst"><code>boolean</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#tryAcquire()">tryAcquire</a></strong>()</code>
|
| <div class="block">Acquires a permit from this semaphore, only if one is available at the time of invocation.</div>
|
| </td>
|
| </tr>
|
| <tr class="altColor">
|
| <td class="colFirst"><code>boolean</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#tryAcquire(int)">tryAcquire</a></strong>(int permits)</code>
|
| <div class="block">Acquires the given number of permits from this semaphore, only if all are available at the time of invocation.</div>
|
| </td>
|
| </tr>
|
| <tr class="rowColor">
|
| <td class="colFirst"><code>boolean</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#tryAcquire(int,%20long,%20java.util.concurrent.TimeUnit)">tryAcquire</a></strong>(int permits,
|
| long timeout,
|
| <a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/TimeUnit.html?is-external=true" title="class or interface in java.util.concurrent">TimeUnit</a> unit)</code>
|
| <div class="block">Acquires the given number of permits from this semaphore, if all become available within the given waiting time |
| and the current thread has not been <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupted</a>.</div>
|
| </td>
|
| </tr>
|
| <tr class="altColor">
|
| <td class="colFirst"><code>boolean</code></td>
|
| <td class="colLast"><code><strong><a href="../../../org/apache/ignite/IgniteSemaphore.html#tryAcquire(long,%20java.util.concurrent.TimeUnit)">tryAcquire</a></strong>(long timeout,
|
| <a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/TimeUnit.html?is-external=true" title="class or interface in java.util.concurrent">TimeUnit</a> unit)</code>
|
| <div class="block">Acquires a permit from this semaphore, if one becomes available within the given waiting time and the current |
| thread has not been <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupted</a>.</div>
|
| </td>
|
| </tr>
|
| </table>
|
| </li>
|
| </ul>
|
| </li>
|
| </ul>
|
| </div>
|
| <div class="details">
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <!-- ============ METHOD DETAIL ========== -->
|
| <ul class="blockList">
|
| <li class="blockList"><a name="method_detail">
|
| <!-- -->
|
| </a>
|
| <h3>Method Detail</h3>
|
| <a name="name()">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>name</h4>
|
| <pre><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> name()</pre>
|
| <div class="block">Gets name of the semaphore.</div>
|
| <dl><dt><span class="strong">Returns:</span></dt><dd>Name of the semaphore.</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="acquire()">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>acquire</h4>
|
| <pre>void acquire()
|
| throws <a href="../../../org/apache/ignite/IgniteInterruptedException.html" title="class in org.apache.ignite">IgniteInterruptedException</a></pre>
|
| <div class="block">Acquires a permit from this semaphore, blocking until one is available, or the thread is <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupted</a>. |
| |
| <p>Acquires a permit, if one is available and returns immediately, reducing the number of available permits by |
| one. |
| |
| <p>If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies |
| dormant until one of two things happens: <ul> <li>Some other thread invokes the <a href="../../../org/apache/ignite/IgniteSemaphore.html#release()"><code>release()</code></a> method for this |
| semaphore and the current thread is next to be assigned a permit; or <li>Some other thread <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupts</a> the current thread. </ul> |
| |
| <p>If the current thread: <ul> <li>has its interrupted status set on entry to this method; or <li>is <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupted</a> while waiting for a permit, </ul> then <a href="../../../org/apache/ignite/IgniteInterruptedException.html" title="class in org.apache.ignite"><code>IgniteInterruptedException</code></a> is thrown |
| and the current thread's interrupted status is cleared.</div>
|
| <dl><dt><span class="strong">Throws:</span></dt>
|
| <dd><code><a href="../../../org/apache/ignite/IgniteInterruptedException.html" title="class in org.apache.ignite">IgniteInterruptedException</a></code> - if the current thread is interrupted</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="acquireUninterruptibly()">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>acquireUninterruptibly</h4>
|
| <pre>void acquireUninterruptibly()</pre>
|
| <div class="block">Acquires a permit from this semaphore, blocking until one is available. |
| |
| <p>Acquires a permit, if one is available and returns immediately, reducing the number of available permits by |
| one. |
| |
| <p>If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies |
| dormant until some other thread invokes the <a href="../../../org/apache/ignite/IgniteSemaphore.html#release()"><code>release()</code></a> method for this semaphore and the current thread is |
| next to be assigned a permit. |
| |
| <p>If the current thread is <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupted</a> while waiting for a permit then it will |
| continue to wait, but the time at which the thread is assigned a permit may change compared to the time it would |
| have received the permit had no interruption occurred. When the thread does return from this method its |
| interrupt status will be set.</div>
|
| </li>
|
| </ul>
|
| <a name="tryAcquire()">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>tryAcquire</h4>
|
| <pre>boolean tryAcquire()</pre>
|
| <div class="block">Acquires a permit from this semaphore, only if one is available at the time of invocation. |
| |
| <p>Acquires a permit, if one is available and returns immediately, with the value <code>true</code>, reducing the |
| number of available permits by one. |
| |
| <p>If no permit is available then this method will return immediately with the value <code>false</code>.</div>
|
| <dl><dt><span class="strong">Returns:</span></dt><dd><code>true</code> if a permit was acquired and <code>false</code> otherwise</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="tryAcquire(long, java.util.concurrent.TimeUnit)">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>tryAcquire</h4>
|
| <pre>boolean tryAcquire(long timeout,
|
| <a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/TimeUnit.html?is-external=true" title="class or interface in java.util.concurrent">TimeUnit</a> unit)
|
| throws <a href="../../../org/apache/ignite/IgniteInterruptedException.html" title="class in org.apache.ignite">IgniteInterruptedException</a></pre>
|
| <div class="block">Acquires a permit from this semaphore, if one becomes available within the given waiting time and the current |
| thread has not been <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupted</a>. |
| |
| <p>Acquires a permit, if one is available and returns immediately, with the value <code>true</code>, reducing the |
| number of available permits by one. |
| |
| <p>If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies |
| dormant until one of three things happens: <ul> <li>Some other thread invokes the <a href="../../../org/apache/ignite/IgniteSemaphore.html#release()"><code>release()</code></a> method for |
| this semaphore and the current thread is next to be assigned a permit; or <li>Some other thread <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupts</a> the current thread; or <li>The specified waiting time elapses. </ul> |
| |
| <p>If a permit is acquired then the value <code>true</code> is returned. |
| |
| <p>If the current thread: <ul> <li>has its interrupted status set on entry to this method; or <li>is <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupted</a> while waiting to acquire a permit, </ul> then <a href="../../../org/apache/ignite/IgniteInterruptedException.html" title="class in org.apache.ignite"><code>IgniteInterruptedException</code></a> is |
| thrown and the current thread's interrupted status is cleared. |
| |
| <p>If the specified waiting time elapses then the value <code>false</code> is returned. If the time is less than or |
| equal to zero, the method will not wait at all.</div>
|
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>timeout</code> - the maximum time to wait for a permit</dd><dd><code>unit</code> - the time unit of the <code>timeout</code> argument</dd>
|
| <dt><span class="strong">Returns:</span></dt><dd><code>true</code> if a permit was acquired and <code>false</code> if the waiting time elapsed before a permit was |
| acquired</dd>
|
| <dt><span class="strong">Throws:</span></dt>
|
| <dd><code><a href="../../../org/apache/ignite/IgniteInterruptedException.html" title="class in org.apache.ignite">IgniteInterruptedException</a></code> - if the current thread is interrupted</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="acquireUninterruptibly(int)">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>acquireUninterruptibly</h4>
|
| <pre>void acquireUninterruptibly(int permits)</pre>
|
| <div class="block">Acquires the given number of permits from this semaphore, blocking until all are available. |
| |
| <p>Acquires the given number of permits, if they are available, and returns immediately, reducing the number of |
| available permits by the given amount. |
| |
| <p>If insufficient permits are available then the current thread becomes disabled for thread scheduling purposes |
| and lies dormant until some other thread invokes one of the <a href="../../../org/apache/ignite/IgniteSemaphore.html#release()"><code>release</code></a> methods for this |
| semaphore, the current thread is next to be assigned permits and the number of available permits satisfies this |
| request. |
| |
| <p>If the current thread is <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupted</a> while waiting for permits then it will |
| continue to wait and its position in the queue is not affected. When the thread does return from this method its |
| interrupt status will be set.</div>
|
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>permits</code> - the number of permits to acquire</dd>
|
| <dt><span class="strong">Throws:</span></dt>
|
| <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if <code>permits</code> is negative</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="availablePermits()">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>availablePermits</h4>
|
| <pre>int availablePermits()</pre>
|
| <div class="block">Returns the current number of permits available in this semaphore. |
| |
| <p>This method is typically used for debugging and testing purposes.</div>
|
| <dl><dt><span class="strong">Returns:</span></dt><dd>the number of permits available in this semaphore</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="drainPermits()">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>drainPermits</h4>
|
| <pre>int drainPermits()</pre>
|
| <div class="block">Acquires and returns all permits that are immediately available.</div>
|
| <dl><dt><span class="strong">Returns:</span></dt><dd>the number of permits acquired</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="release()">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>release</h4>
|
| <pre>void release()</pre>
|
| <div class="block">Releases a permit, returning it to the semaphore. |
| |
| <p>Releases a permit, increasing the number of available permits by one. If any threads are trying to acquire a |
| permit, then one is selected and given the permit that was just released. That thread is (re)enabled for thread |
| scheduling purposes. |
| |
| <p>There is no requirement that a thread that releases a permit must have acquired that permit by calling <a href="../../../org/apache/ignite/IgniteSemaphore.html#acquire()"><code>acquire()</code></a>. Correct usage of a semaphore is established by programming convention in the application.</div>
|
| </li>
|
| </ul>
|
| <a name="tryAcquire(int, long, java.util.concurrent.TimeUnit)">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>tryAcquire</h4>
|
| <pre>boolean tryAcquire(int permits,
|
| long timeout,
|
| <a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/TimeUnit.html?is-external=true" title="class or interface in java.util.concurrent">TimeUnit</a> unit)
|
| throws <a href="../../../org/apache/ignite/IgniteInterruptedException.html" title="class in org.apache.ignite">IgniteInterruptedException</a></pre>
|
| <div class="block">Acquires the given number of permits from this semaphore, if all become available within the given waiting time |
| and the current thread has not been <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupted</a>. |
| |
| <p>Acquires the given number of permits, if they are available and returns immediately, with the value <code>true</code>, reducing the number of available permits by the given amount. |
| |
| <p>If insufficient permits are available then the current thread becomes disabled for thread scheduling purposes |
| and lies dormant until one of three things happens: <ul> <li>Some other thread invokes one of the <a href="../../../org/apache/ignite/IgniteSemaphore.html#release()"><code>release</code></a> methods for this semaphore, the current thread is next to be assigned permits and the number |
| of available permits satisfies this request; or <li>Some other thread <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupts</a> |
| the current thread; or <li>The specified waiting time elapses. </ul> |
| |
| <p>If the permits are acquired then the value <code>true</code> is returned. |
| |
| <p>If the current thread: <ul> <li>has its interrupted status set on entry to this method; or <li>is <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupted</a> while waiting to acquire the permits, </ul> then <a href="../../../org/apache/ignite/IgniteInterruptedException.html" title="class in org.apache.ignite"><code>IgniteInterruptedException</code></a> |
| is thrown and the current thread's interrupted status is cleared. Any permits that were to be assigned to this |
| thread, are instead assigned to other threads trying to acquire permits, as if the permits had been made |
| available by a call to <a href="../../../org/apache/ignite/IgniteSemaphore.html#release()"><code>release()</code></a>. |
| |
| <p>If the specified waiting time elapses then the value <code>false</code> is returned. If the time is less than or |
| equal to zero, the method will not wait at all. Any permits that were to be assigned to this thread, are instead |
| assigned to other threads trying to acquire permits, as if the permits had been made available by a call to |
| <a href="../../../org/apache/ignite/IgniteSemaphore.html#release()"><code>release()</code></a>.</div>
|
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>permits</code> - the number of permits to acquire</dd><dd><code>timeout</code> - the maximum time to wait for the permits</dd><dd><code>unit</code> - the time unit of the <code>timeout</code> argument</dd>
|
| <dt><span class="strong">Returns:</span></dt><dd><code>true</code> if all permits were acquired and <code>false</code> if the waiting time elapsed before all |
| permits were acquired</dd>
|
| <dt><span class="strong">Throws:</span></dt>
|
| <dd><code><a href="../../../org/apache/ignite/IgniteInterruptedException.html" title="class in org.apache.ignite">IgniteInterruptedException</a></code> - if the current thread is interrupted</dd>
|
| <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if <code>permits</code> is negative</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="tryAcquire(int)">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>tryAcquire</h4>
|
| <pre>boolean tryAcquire(int permits)</pre>
|
| <div class="block">Acquires the given number of permits from this semaphore, only if all are available at the time of invocation. |
| |
| <p>Acquires the given number of permits, if they are available, and returns immediately, with the value <code>true</code>, reducing the number of available permits by the given amount. |
| |
| <p>If insufficient permits are available then this method will return immediately with the value <code>false</code> |
| and the number of available permits is unchanged. |
| |
| <p>If you want to honor the failoverSafe setting, then use <a href="../../../org/apache/ignite/IgniteSemaphore.html#tryAcquire(int,%20long,%20java.util.concurrent.TimeUnit)"><code>tryAcquire(permits, 0, TimeUnit.SECONDS) </code></a> which is almost equivalent (it also detects interruption).</div>
|
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>permits</code> - the number of permits to acquire</dd>
|
| <dt><span class="strong">Returns:</span></dt><dd><code>true</code> if the permits were acquired and <code>false</code> otherwise</dd>
|
| <dt><span class="strong">Throws:</span></dt>
|
| <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if <code>permits</code> is negative</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="acquire(int)">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>acquire</h4>
|
| <pre>void acquire(int permits)
|
| throws <a href="../../../org/apache/ignite/IgniteInterruptedException.html" title="class in org.apache.ignite">IgniteInterruptedException</a></pre>
|
| <div class="block">Acquires the given number of permits from this semaphore, blocking until all are available, or the thread is |
| <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupted</a>. |
| |
| <p>Acquires the given number of permits, if they are available, and returns immediately, reducing the number of |
| available permits by the given amount. |
| |
| <p>If insufficient permits are available then the current thread becomes disabled for thread scheduling purposes |
| and lies dormant until one of two things happens: <ul> <li>Some other thread invokes one of the <a href="../../../org/apache/ignite/IgniteSemaphore.html#release()"><code>release</code></a> methods for this semaphore, the current thread is next to be assigned permits and the number of |
| available permits satisfies this request; or <li>Some other thread <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupts</a> the |
| current thread. </ul> |
| |
| <p>If the current thread: <ul> <li>has its interrupted status set on entry to this method; or <li>is <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html?is-external=true#interrupt()" title="class or interface in java.lang">interrupted</a> while waiting for a permit, </ul> then <a href="../../../org/apache/ignite/IgniteInterruptedException.html" title="class in org.apache.ignite"><code>IgniteInterruptedException</code></a> is thrown |
| and the current thread's interrupted status is cleared. Any permits that were to be assigned to this thread are |
| instead assigned to other threads trying to acquire permits, as if permits had been made available by a call to |
| <a href="../../../org/apache/ignite/IgniteSemaphore.html#release()"><code>release()</code></a>.</div>
|
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>permits</code> - the number of permits to acquire</dd>
|
| <dt><span class="strong">Throws:</span></dt>
|
| <dd><code><a href="../../../org/apache/ignite/IgniteInterruptedException.html" title="class in org.apache.ignite">IgniteInterruptedException</a></code> - if the current thread is interrupted</dd>
|
| <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if <code>permits</code> is negative</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="release(int)">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>release</h4>
|
| <pre>void release(int permits)</pre>
|
| <div class="block">Releases the given number of permits, returning them to the semaphore. |
| |
| <p>Releases the given number of permits, increasing the number of available permits by that amount. If any |
| threads are trying to acquire permits, then one is selected and given the permits that were just released. If the |
| number of available permits satisfies that thread's request then that thread is (re)enabled for thread scheduling |
| purposes; otherwise the thread will wait until sufficient permits are available. If there are still permits |
| available after this thread's request has been satisfied, then those permits are assigned in turn to other |
| threads trying to acquire permits. |
| |
| <p>There is no requirement that a thread that releases a permit must have acquired that permit by calling <a href="../../../org/apache/ignite/IgniteSemaphore.html#acquire()"><code>acquire</code></a>. Correct usage of a semaphore is established by programming convention in the |
| application.</div>
|
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>permits</code> - the number of permits to release</dd>
|
| <dt><span class="strong">Throws:</span></dt>
|
| <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if <code>permits</code> is negative</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="isFailoverSafe()">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>isFailoverSafe</h4>
|
| <pre>boolean isFailoverSafe()</pre>
|
| <div class="block">Returns <code>true</code> if this semaphore is safe to use after node failure. |
| If not, IgniteInterruptedException is thrown on every other node after node failure.</div>
|
| <dl><dt><span class="strong">Returns:</span></dt><dd><code>true</code> if this semaphore has failoverSafe set true</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="hasQueuedThreads()">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>hasQueuedThreads</h4>
|
| <pre>boolean hasQueuedThreads()</pre>
|
| <div class="block">Queries whether any threads are waiting to acquire. Note that because cancellations may occur at any time, a |
| <code>true</code> return does not guarantee that any other thread will ever acquire. This method is designed |
| primarily for use in monitoring of the system state.</div>
|
| <dl><dt><span class="strong">Returns:</span></dt><dd><code>true</code> if there may be other threads waiting to acquire the lock</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="getQueueLength()">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>getQueueLength</h4>
|
| <pre>int getQueueLength()</pre>
|
| <div class="block">Returns an estimate of the number of nodes waiting to acquire. The value is only an estimate because the number |
| of nodes that are waiting may change dynamically while this method traverses internal data structures. This method is designed |
| for use in monitoring of the system state, not for synchronization control.</div>
|
| <dl><dt><span class="strong">Returns:</span></dt><dd>the estimated number of nodes waiting for this lock</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="isBroken()">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>isBroken</h4>
|
| <pre>boolean isBroken()</pre>
|
| <div class="block">Gets <code>broken</code> status of the semaphore.</div>
|
| <dl><dt><span class="strong">Returns:</span></dt><dd><code>True</code> if a node failed on this semaphore and failoverSafe flag was set to false, <code>false</code> otherwise.</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="removed()">
|
| <!-- -->
|
| </a>
|
| <ul class="blockList">
|
| <li class="blockList">
|
| <h4>removed</h4>
|
| <pre>boolean removed()</pre>
|
| <div class="block">Gets <code>removed</code> status of the semaphore.</div>
|
| <dl><dt><span class="strong">Returns:</span></dt><dd><code>True</code> if semaphore was removed from cache, <code>false</code> otherwise.</dd></dl>
|
| </li>
|
| </ul>
|
| <a name="close()">
|
| <!-- -->
|
| </a>
|
| <ul class="blockListLast">
|
| <li class="blockList">
|
| <h4>close</h4>
|
| <pre>void close()</pre>
|
| <div class="block">Removes this semaphore.</div>
|
| <dl>
|
| <dt><strong>Specified by:</strong></dt>
|
| <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html?is-external=true#close()" title="class or interface in java.lang">close</a></code> in interface <code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html?is-external=true" title="class or interface in java.lang">AutoCloseable</a></code></dd>
|
| <dt><strong>Specified by:</strong></dt>
|
| <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/Closeable.html?is-external=true#close()" title="class or interface in java.io">close</a></code> in interface <code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</a></code></dd>
|
| <dt><span class="strong">Throws:</span></dt>
|
| <dd><code><a href="../../../org/apache/ignite/IgniteException.html" title="class in org.apache.ignite">IgniteException</a></code> - If operation failed.</dd></dl>
|
| </li>
|
| </ul>
|
| </li>
|
| </ul>
|
| </li>
|
| </ul>
|
| </div>
|
| </div>
|
| <!-- ========= END OF CLASS DATA ========= -->
|
| <!-- ======= START OF BOTTOM NAVBAR ====== -->
|
| <div class="bottomNav"><a name="navbar_bottom">
|
| <!-- -->
|
| </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
|
| <!-- -->
|
| </a>
|
| <ul class="navList" title="Navigation">
|
| <li><a href="../../../overview-summary.html">Overview</a></li>
|
| <li><a href="package-summary.html">Package</a></li>
|
| <li class="navBarCell1Rev">Class</li>
|
| <li><a href="class-use/IgniteSemaphore.html">Use</a></li>
|
| <li><a href="package-tree.html">Tree</a></li>
|
| <li><a href="../../../deprecated-list.html">Deprecated</a></li>
|
| <li><a href="../../../index-all.html">Index</a></li>
|
| <li><a href="../../../help-doc.html">Help</a></li>
|
| </ul>
|
| <div class="aboutLanguage"><em>Ignite - In-Memory Data Fabric</em></div>
|
| </div>
|
| <div class="subNav">
|
| <ul class="navList">
|
| <li><a href="../../../org/apache/ignite/IgniteScheduler.html" title="interface in org.apache.ignite"><span class="strong">Prev Class</span></a></li>
|
| <li><a href="../../../org/apache/ignite/IgniteServices.html" title="interface in org.apache.ignite"><span class="strong">Next Class</span></a></li>
|
| </ul>
|
| <ul class="navList">
|
| <li><a href="../../../index.html?org/apache/ignite/IgniteSemaphore.html" target="_top">Frames</a></li>
|
| <li><a href="IgniteSemaphore.html" target="_top">No Frames</a></li>
|
| </ul>
|
| <ul class="navList" id="allclasses_navbar_bottom">
|
| <li><a href="../../../allclasses-noframe.html">All Classes</a></li>
|
| </ul>
|
| <div>
|
| <script type="text/javascript"><!--
|
| allClassesLink = document.getElementById("allclasses_navbar_bottom");
|
| if(window==top) {
|
| allClassesLink.style.display = "block";
|
| }
|
| else {
|
| allClassesLink.style.display = "none";
|
| }
|
| //-->
|
| </script>
|
| </div>
|
| <div>
|
| <ul class="subNavList">
|
| <li>Summary: </li>
|
| <li>Nested | </li>
|
| <li>Field | </li>
|
| <li>Constr | </li>
|
| <li><a href="#method_summary">Method</a></li>
|
| </ul>
|
| <ul class="subNavList">
|
| <li>Detail: </li>
|
| <li>Field | </li>
|
| <li>Constr | </li>
|
| <li><a href="#method_detail">Method</a></li>
|
| </ul>
|
| </div>
|
| <a name="skip-navbar_bottom">
|
| <!-- -->
|
| </a></div>
|
| <!-- ======== END OF BOTTOM NAVBAR ======= -->
|
| <p class="legalCopy"><small><table width="100%" border="0" cellspacing=0 cellpadding=0 style="padding: 5px"> <tr> <td> <table style="padding-left: 0; margin: 0"> <tbody style="padding: 0; margin: 0"> <tr style="padding: 0; margin: 0"> <td> <a target=_blank href="https://apache.org/projects/ignite.html"><nobr>2015 Copyright © Apache Software Foundation</nobr></a> </td> </tr> </tbody> </table> </td> <td width="100%" align="right" valign="center"> <a href="https://twitter.com/ApacheIgnite" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @ApacheIgnite</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script> </td> </tr> <tr> <td colspan="2" valign="top" align="left"> <table style="padding-left: 0; margin: 0"> <tbody style="padding: 0; margin: 0"> <tr style="padding: 0; margin: 0"> <td> <b>Ignite Fabric</b> </td> <td>: ver. <strong>1.5.0-final-SNAPSHOT</strong> </td> </tr> <tr style="padding: 0; margin: 0"> <td> <b>Release Date</b> </td> <td>: Äåêàáðü 21 2015 </td> </tr> </tbody> </table> </td> </tr> </table></small></p>
|
| <!--FOOTER--><script type='text/javascript'>SyntaxHighlighter.all();dp.SyntaxHighlighter.HighlightAll('code');</script> |
| </body> |
|
|
| </html>
|