Path: blob/master/src/hotspot/os/bsd/semaphore_bsd.hpp
40949 views
/*1* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef OS_BSD_SEMAPHORE_BSD_HPP25#define OS_BSD_SEMAPHORE_BSD_HPP2627#include "utilities/globalDefinitions.hpp"2829#ifndef __APPLE__30// Use POSIX semaphores.31# include "semaphore_posix.hpp"3233#else34// OS X doesn't support unamed POSIX semaphores, so the implementation in os_posix.cpp can't be used.35# include "memory/allocation.hpp"36# include <mach/semaphore.h>3738class OSXSemaphore : public CHeapObj<mtInternal>{39semaphore_t _semaphore;4041NONCOPYABLE(OSXSemaphore);4243public:44OSXSemaphore(uint value = 0);45~OSXSemaphore();4647void signal(uint count = 1);4849void wait();5051bool trywait();5253// wait until the given relative time elapses54bool timedwait(int64_t millis);55};5657typedef OSXSemaphore SemaphoreImpl;5859#endif // __APPLE__6061#endif // OS_BSD_SEMAPHORE_BSD_HPP626364