Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/thread
In directory sc8-pr-cvs1:/tmp/cvs-serv9738/src/thread
Modified Files:
Condition.cpp Condition.h
Log Message:
28/12/2003 Mikael Barbeaux
* Fixed Condition bugs under Win 95 / 98 / Me. The
SignalObjectAndWait kernel function wasn't implemented
on thoses operating systems.
Index: Condition.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/thread/Condition.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Condition.cpp 24 Dec 2003 13:03:54 -0000 1.2
+++ Condition.cpp 28 Dec 2003 12:27:24 -0000 1.3
@@ -88,8 +88,20 @@
/* Waits indefinitively for the semaphore to
release the mutex. */
HANDLE *mutex_t = (HANDLE*) mutex;
- if(::SignalObjectAndWait(*mutex_t, condition->semaphore,
- INFINITE, false) != WAIT_OBJECT_0) {
+ DWORD ret = ::SignalObjectAndWait(*mutex_t,
+ condition->semaphore,
+ INFINITE, false);
+ /**
+ * Under Windows 95/98/Me, SignalObjectAndWait
+ * kernel function isn't implemented. In that
+ * case, you need to make the signal manually...
+ */
+ if(GetLastError() == 120) {
+ // Signals and waits for object
+ unlock();
+ ret = WaitForSingleObject(condition->semaphore, INFINITE);
+ }
+ if(ret != WAIT_OBJECT_0) {
// semaphore is invalid
unlock();
throw ThreadException(ConditionExcp, "Invalid semaphore.",
@@ -104,8 +116,20 @@
LeaveCriticalSection(&(condition->waiting_lock));
if(last_waiter) {
// Wait for all waiting threads to leave the mutex.
- if(::SignalObjectAndWait(condition->waiters_done, *mutex_t,
- INFINITE, false) != WAIT_OBJECT_0) {
+ DWORD ret = ::SignalObjectAndWait(condition->waiters_done,
+ *mutex_t, INFINITE, false);
+
+ /**
+ * Under Windows 95/98/Me, SignalObjectAndWait
+ * kernel function isn't implemented. In that
+ * case, you need to make the signal manually...
+ */
+ if(GetLastError() == 120) {
+ PulseEvent(condition->waiters_done);
+ ret = WaitForSingleObject(*mutex, INFINITE);
+ }
+
+ if(ret != WAIT_OBJECT_0) {
// the mutex is invalid
unlock();
throw ThreadException(ConditionExcp, "Invalid mutex.",
Index: Condition.h
===================================================================
RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/thread/Condition.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Condition.h 24 Dec 2003 13:03:54 -0000 1.2
+++ Condition.h 28 Dec 2003 12:27:24 -0000 1.3
@@ -35,7 +35,7 @@
#define _WIN32_WINNT 0x0400
#endif
#include <windows.h>
-
+
typedef struct {
// Number of threads waiting for the condition
int nb_waiting;
|