~saiarcot895/ubuntu/trusty/openscenegraph/armhf-support

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/OpenThreads/win32/Win32ConditionPrivateData.h

  • Committer: Bazaar Package Importer
  • Author(s): Loic Dachary (OuoU)
  • Date: 2009-03-23 14:08:20 UTC
  • mfrom: (1.1.7 upstream) (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090323140820-i4j3jozdlhyn4lre
rules prevent lib64 with -D LIB_POSTFIX="" (Closes: #517671)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#ifndef _WINDOWS_
23
23
#define WIN32_LEAN_AND_MEAN
 
24
#define _WIN32_WINNT 0x0400
24
25
#include <windows.h>
25
26
#endif
26
27
 
43
44
 
44
45
    Win32ConditionPrivateData ()
45
46
        :waiters_(0), 
 
47
         was_broadcast_(0),
46
48
         sema_(CreateSemaphore(NULL,0,0x7fffffff,NULL)),
47
49
         waiters_done_(CreateEvent(NULL,FALSE,FALSE,NULL))
48
50
    {
68
70
            // Wake up all the waiters.
69
71
            ReleaseSemaphore(sema_.get(),waiters_,NULL);
70
72
 
71
 
                        cooperativeWait(waiters_done_.get(), INFINITE);
 
73
            cooperativeWait(waiters_done_.get(), INFINITE);
72
74
 
73
75
            //end of broadcasting
74
76
            was_broadcast_ = 0;
103
105
 
104
106
        // wait in timeslices, giving testCancel() a change to
105
107
        // exit the thread if requested.
106
 
                try {
107
 
                        DWORD dwResult =        cooperativeWait(sema_.get(), timeout_ms);
108
 
                    if(dwResult != WAIT_OBJECT_0)
109
 
                                result = (int)dwResult;
110
 
                }
111
 
                catch(...){
112
 
                        // thread is canceled in cooperative wait , do cleanup
113
 
                    InterlockedDecrement(&waiters_);
114
 
                        long w = InterlockedGet(&waiters_);
115
 
                        int last_waiter = was_broadcast_ && w == 0;
116
 
 
117
 
                        if (last_waiter)  SetEvent(waiters_done_.get());
118
 
                        // rethrow
119
 
                        throw;
120
 
                }
121
 
 
122
 
                
 
108
        try {
 
109
              DWORD dwResult = cooperativeWait(sema_.get(), timeout_ms);
 
110
            if(dwResult != WAIT_OBJECT_0)
 
111
                result = (int)dwResult;
 
112
        }
 
113
        catch(...){
 
114
            // thread is canceled in cooperative wait , do cleanup
 
115
            InterlockedDecrement(&waiters_);
 
116
            long w = InterlockedGet(&waiters_);
 
117
            int last_waiter = was_broadcast_ && w == 0;
 
118
 
 
119
            if (last_waiter)  SetEvent(waiters_done_.get());
 
120
            // rethrow
 
121
            throw;
 
122
        }
 
123
 
 
124
        
123
125
        // We're ready to return, so there's one less waiter.
124
126
        InterlockedDecrement(&waiters_);
125
127
        long w = InterlockedGet(&waiters_);