< prev index next >

src/share/vm/runtime/semaphore.cpp

Print this page




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "utilities/debug.hpp"
  27 #include "runtime/semaphore.hpp"
  28 
  29 // Implements the limited, platform independent Semaphore API.
  30 Semaphore::Semaphore(uint value) : _impl(value) {}
  31 Semaphore::~Semaphore()            {}
  32 void Semaphore::signal(uint count) { _impl.signal(count); }
  33 void Semaphore::wait()             { _impl.wait(); }
  34 
  35 /////////////// Unit tests ///////////////
  36 
  37 #ifndef PRODUCT
  38 
  39 static void test_semaphore_single_separate(uint count) {
  40   Semaphore sem(0);
  41 
  42   for (uint i = 0; i < count; i++) {
  43     sem.signal();
  44   }
  45 
  46   for (uint i = 0; i < count; i++) {
  47     sem.wait();
  48   }
  49 }
  50 
  51 static void test_semaphore_single_combined(uint count) {
  52   Semaphore sem(0);
  53 
  54   for (uint i = 0; i < count; i++) {




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "utilities/debug.hpp"
  27 #include "runtime/semaphore.hpp"
  28 






  29 /////////////// Unit tests ///////////////
  30 
  31 #ifndef PRODUCT
  32 
  33 static void test_semaphore_single_separate(uint count) {
  34   Semaphore sem(0);
  35 
  36   for (uint i = 0; i < count; i++) {
  37     sem.signal();
  38   }
  39 
  40   for (uint i = 0; i < count; i++) {
  41     sem.wait();
  42   }
  43 }
  44 
  45 static void test_semaphore_single_combined(uint count) {
  46   Semaphore sem(0);
  47 
  48   for (uint i = 0; i < count; i++) {


< prev index next >