< prev index next >
src/os/windows/vm/os_windows.cpp
Print this page
*** 68,77 ****
--- 68,78 ----
#include "services/runtimeService.hpp"
#include "utilities/decoder.hpp"
#include "utilities/defaultStream.hpp"
#include "utilities/events.hpp"
#include "utilities/growableArray.hpp"
+ #include "utilities/semaphore.hpp"
#include "utilities/vmError.hpp"
#ifdef _DEBUG
#include <crtdbg.h>
#endif
*** 1893,1902 ****
--- 1894,1940 ----
error = errno;
}
return (int)error;
}
+ Semaphore::Semaphore(uint value, uint max) {
+ _semaphore = ::CreateSemaphore(NULL, value, max, NULL);
+
+ guarantee(_semaphore != NULL, err_msg("CreateSemaphore failed: %ld", GetLastError()));
+ }
+
+ Semaphore::~Semaphore() {
+ if (_semaphore != NULL) {
+ ::CloseHandle(_semaphore);
+ }
+ }
+
+ void Semaphore::signal(uint count) {
+ BOOL ret = ::ReleaseSemaphore(_semaphore, count, NULL);
+
+ guarantee(ret != 0, err_msg("ReleaseSemaphore failed: %d", GetLastError()));
+ }
+
+ void Semaphore::signal() {
+ signal(1);
+ }
+
+ void Semaphore::wait() {
+ DWORD ret = ::WaitForSingleObject(_semaphore, INFINITE);
+ guarantee(ret == WAIT_OBJECT_0, err_msg("WaitForSingleObject failed: %d", GetLastError()));
+ }
+
+ bool Semaphore::trywait() {
+ Unimplemented();
+ return false;
+ }
+
+ bool Semaphore::timedwait(unsigned int sec, int nsec) {
+ Unimplemented();
+ return false;
+ }
+
// sun.misc.Signal
// NOTE that this is a workaround for an apparent kernel bug where if
// a signal handler for SIGBREAK is installed then that signal handler
// takes priority over the console control handler for CTRL_CLOSE_EVENT.
// See bug 4416763.
< prev index next >