7068 " |
7069 " |
7069 self createMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0' |
7070 self createMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0' |
7070 self releaseMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0' |
7071 self releaseMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0' |
7071 " |
7072 " |
7072 |
7073 |
7073 "Modified: / 03-08-2010 / 16:30:37 / cg" |
7074 "Modified: / 03-08-2010 / 16:57:36 / cg" |
7074 ! |
7075 ! |
7075 |
7076 |
7076 existsMutexNamed: name |
7077 existsMutexNamed: name |
7077 |
|
7078 |handle lastErrorCode handleAndLastErrorCode| |
7078 |handle lastErrorCode handleAndLastErrorCode| |
7079 |
7079 |
7080 handleAndLastErrorCode := self createMutexNamed: name. |
7080 handleAndLastErrorCode := self createMutexNamed: name. |
7081 handle := handleAndLastErrorCode first. |
7081 handle := handleAndLastErrorCode first. |
7082 lastErrorCode := handleAndLastErrorCode second. |
7082 lastErrorCode := handleAndLastErrorCode second. |
7083 "/ self assert: lastErrorCode == 0. |
7083 "/ self assert: lastErrorCode == 0. |
7084 ^ handle isNil |
7084 ^ handle isNil |
7085 or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS" |
7085 or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS" |
7086 or:[ lastErrorCode == 5 "ERROR_ACCESS_DENIED"]] |
7086 or:[ lastErrorCode == 5 "ERROR_ACCESS_DENIED"]] |
|
7087 |
|
7088 "Modified: / 03-08-2010 / 16:59:41 / cg" |
7087 ! |
7089 ! |
7088 |
7090 |
7089 openMutexNamed: name |
7091 openMutexNamed: name |
7090 |
7092 "If the function succeeds, the return value is a handle to the mutex object. |
7091 " |
7093 If the function fails, the return value is NULL. To get extended error information, call GetLastError. |
7092 If the function succeeds, the return value is a handle to the mutex object. |
7094 If a named mutex does not exist, the function fails and GetLastError returns ERROR_FILE_NOT_FOUND." |
7093 If the function fails, the return value is NULL. To get extended error information, call GetLastError. |
|
7094 If a named mutex does not exist, the function fails and GetLastError returns ERROR_FILE_NOT_FOUND. |
|
7095 " |
|
7096 |
7095 |
7097 |handle | |
7096 |handle | |
7098 |
7097 |
7099 handle := self primOpenMutex:nil initialOwner: true name: name. |
7098 handle := self primOpenMutex:nil initialOwner: true name: name. |
7100 "/ lastErrorCode := self primGetLastError. |
7099 "/ lastErrorCode := self primGetLastError. |
7101 "/ lastErrorCode = 2 ifTrue:[Transcript showCR: 'Mutex does not exist (GetLastError = ERROR_FILE_NOT_FOUND)'.]. |
7100 "/ lastErrorCode = 2 ifTrue:[Transcript showCR: 'Mutex does not exist (GetLastError = ERROR_FILE_NOT_FOUND)'.]. |
7102 "/ lastErrorCode = 5 ifTrue:[Transcript showCR: 'Mutex not accesible (GetLastError = ERROR_ACCESS_DENIED)'.]. |
7101 "/ lastErrorCode = 5 ifTrue:[Transcript showCR: 'Mutex not accesible (GetLastError = ERROR_ACCESS_DENIED)'.]. |
7103 (handle isNil or:[handle address ~~ 0]) ifFalse:[ |
7102 (handle isNil or:[handle address ~~ 0]) ifFalse:[ |
7104 Transcript showCR: 'OpenMutexNamed: "', name printString, '" failed'. |
7103 Transcript showCR: 'OpenMutexNamed: "', name printString, '" failed'. |
7105 ^ nil. |
7104 ^ nil. |
7106 ]. |
7105 ]. |
7107 |
7106 |
7108 ^ handle |
7107 ^ handle |
7109 |
7108 |
7110 |
7109 |
7111 " |
7110 " |
7112 self openMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0' |
7111 self openMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0' |
7113 " |
7112 " |
|
7113 |
|
7114 "Modified: / 03-08-2010 / 16:59:37 / cg" |
7114 ! |
7115 ! |
7115 |
7116 |
7116 primCreateMutex:lpSecurityDescriptor initialOwner: bInitialOwner name: lpName |
7117 primCreateMutex:lpSecurityDescriptor initialOwner: bInitialOwner name: lpName |
7117 |
7118 "If the function succeeds, the return value is a handle to the newly created mutex object. |
7118 " |
|
7119 If the function succeeds, the return value is a handle to the newly created mutex object. |
|
7120 If the function fails, the return value is NULL. |
7119 If the function fails, the return value is NULL. |
7121 If the mutex is a named mutex and the object existed before this function call, the return value is a handle to the existing object. |
7120 If the mutex is a named mutex and the object existed before this function call, the return value is a handle to the existing object." |
7122 " |
|
7123 |
7121 |
7124 <apicall: handle "CreateMutexA" (lpstr bool lpstr) module: "kernel32.dll" > |
7122 <apicall: handle "CreateMutexA" (lpstr bool lpstr) module: "kernel32.dll" > |
|
7123 |
|
7124 "Modified: / 03-08-2010 / 16:59:26 / cg" |
7125 ! |
7125 ! |
7126 |
7126 |
7127 primOpenMutex:lpSecurityDescriptor initialOwner: bInitialOwner name: lpName |
7127 primOpenMutex:lpSecurityDescriptor initialOwner: bInitialOwner name: lpName |
7128 |
7128 "If the function succeeds, the return value is a handle to the mutex object. |
7129 " |
7129 If the function fails, the return value is NULL. To get extended error information, call GetLastError. |
7130 If the function succeeds, the return value is a handle to the mutex object. |
7130 If a named mutex does not exist, the function fails and GetLastError returns ERROR_FILE_NOT_FOUND." |
7131 If the function fails, the return value is NULL. To get extended error information, call GetLastError. |
|
7132 If a named mutex does not exist, the function fails and GetLastError returns ERROR_FILE_NOT_FOUND. |
|
7133 " |
|
7134 |
7131 |
7135 <apicall: handle "OpenMutexA" (lpstr bool lpstr) module: "kernel32.dll" > |
7132 <apicall: handle "OpenMutexA" (lpstr bool lpstr) module: "kernel32.dll" > |
|
7133 |
|
7134 "Modified: / 03-08-2010 / 16:59:11 / cg" |
7136 ! |
7135 ! |
7137 |
7136 |
7138 primReleaseMutex: hMutex |
7137 primReleaseMutex: hMutex |
7139 |
7138 "If the function succeeds, the return value is nonzero. |
7140 " |
7139 If the function fails, the return value is zero." |
7141 If the function succeeds, the return value is nonzero. |
|
7142 If the function fails, the return value is zero. |
|
7143 " |
|
7144 |
7140 |
7145 <apicall: bool "ReleaseMutex" (handle) module: "kernel32.dll" > |
7141 <apicall: bool "ReleaseMutex" (handle) module: "kernel32.dll" > |
|
7142 |
|
7143 "Modified: / 03-08-2010 / 16:59:55 / cg" |
7146 ! |
7144 ! |
7147 |
7145 |
7148 primWaitForSingleObject: handle milliseconds: dwMilliseconds |
7146 primWaitForSingleObject: handle milliseconds: dwMilliseconds |
7149 |
7147 "If the function succeeds, the return value indicates the event that caused the function to return. |
7150 " |
7148 If the function fails, the return value is WAIT_FAILED ((DWORD)0xFFFFFFFF)." |
7151 If the function succeeds, the return value indicates the event that caused the function to return. |
|
7152 If the function fails, the return value is WAIT_FAILED ((DWORD)0xFFFFFFFF). |
|
7153 " |
|
7154 |
7149 |
7155 <apicall: dword "WaitForSingleObject" (handle dword) module: "kernel32.dll" > |
7150 <apicall: dword "WaitForSingleObject" (handle dword) module: "kernel32.dll" > |
|
7151 |
|
7152 "Modified: / 03-08-2010 / 17:00:02 / cg" |
7156 ! |
7153 ! |
7157 |
7154 |
7158 releaseMutex: hMutex |
7155 releaseMutex: hMutex |
7159 |
|
7160 "Returns true if the Mutex was released. Otherwise, returns false." |
7156 "Returns true if the Mutex was released. Otherwise, returns false." |
7161 |
7157 |
7162 | released| |
7158 | released| |
7163 |
7159 |
7164 hMutex isNil ifTrue:[ |
7160 hMutex isNil ifTrue:[ |
7165 Transcript showCR: 'hMutex is nil - cannot release'. |
7161 Transcript showCR: 'hMutex is nil - cannot release'. |
7166 ^ false |
7162 ^ false |
7167 ]. |
7163 ]. |
7168 released := self primReleaseMutex: hMutex. |
7164 released := self primReleaseMutex: hMutex. |
7169 released ifFalse:[Transcript showCR: 'Release Mutex failed'.]. |
7165 released ifFalse:[Transcript showCR: 'Release Mutex failed'.]. |
7170 ^ released |
7166 ^ released |
|
7167 |
|
7168 "Modified: / 03-08-2010 / 17:00:05 / cg" |
7171 ! |
7169 ! |
7172 |
7170 |
7173 releaseMutexNamed: name |
7171 releaseMutexNamed: name |
7174 |
|
7175 "Returns true if the Mutex was released. Otherwise, returns false." |
7172 "Returns true if the Mutex was released. Otherwise, returns false." |
7176 |
7173 |
7177 | hMutex | |
7174 | hMutex | |
|
7175 |
7178 hMutex := self openMutexNamed: name. |
7176 hMutex := self openMutexNamed: name. |
7179 hMutex isNil ifTrue:[ |
7177 hMutex isNil ifTrue:[ |
7180 Transcript showCR: 'Cannot release Mutex named: "', name printString,'"'. |
7178 Transcript showCR: 'Cannot release Mutex named: "', name printString,'"'. |
7181 ^ false |
7179 ^ false |
7182 ]. |
7180 ]. |
7183 ^ self releaseMutex: hMutex. |
7181 ^ self releaseMutex: hMutex. |
|
7182 |
|
7183 "Modified: / 03-08-2010 / 16:58:25 / cg" |
7184 ! |
7184 ! |
7185 |
7185 |
7186 waitForSingleObject: handle |
7186 waitForSingleObject: handle |
7187 |
|
7188 |result| |
7187 |result| |
7189 |
7188 |
7190 result := self primWaitForSingleObject: handle milliseconds: 500. |
7189 result := self primWaitForSingleObject: handle milliseconds: 500. |
7191 ^ result |
7190 ^ result |
|
7191 |
|
7192 "Modified: / 03-08-2010 / 17:00:10 / cg" |
7192 ! ! |
7193 ! ! |
7193 |
7194 |
7194 !Win32OperatingSystem class methodsFor:'os queries'! |
7195 !Win32OperatingSystem class methodsFor:'os queries'! |
7195 |
7196 |
7196 executableFileExtensions |
7197 executableFileExtensions |