# HG changeset patch # User Jan Vrany # Date 1692365154 -3600 # Node ID fdfe1a981363c1a5fad205837d1022a406f06996 # Parent 2d0631d5ed1a518fbc2af375968cdfd3a78ed8e9 Compatibility: allow ports to customize semaphore / mutex creation This commit adds new port methods: `#newSemaphore` and `#newMutex`. This allows ports to return customized objects. This is needed to accomodate different implementations / behaviors of semaphores among dialects (e.g, Pharo) diff -r 2d0631d5ed1a -r fdfe1a981363 GDBDebugger.st --- a/GDBDebugger.st Fri Aug 18 14:10:59 2023 +0100 +++ b/GDBDebugger.st Fri Aug 18 14:25:54 2023 +0100 @@ -418,7 +418,7 @@ "/ self "/ assert:Processor activeProcess ~~ connection eventDispatchProcess "/ message:'Cannot send commands from within event dispatching process. Would deadlock'. - blocker := Semaphore new. + blocker := GDBPortlib current newSemaphore. self send: command andWithResultDo: [ :r | result := r. blocker signal @@ -444,7 +444,7 @@ "Created: / 02-06-2014 / 23:45:43 / Jan Vrany " "Modified: / 26-03-2018 / 21:19:59 / jv" "Modified: / 28-01-2019 / 21:26:28 / Jan Vrany " - "Modified: / 22-02-2022 / 13:17:28 / Jan Vrany " + "Modified: / 18-08-2023 / 14:17:04 / Jan Vrany " ! send:command andWaitFor:eventHandlers @@ -733,7 +733,7 @@ "Created: / 05-06-2017 / 17:05:11 / Jan Vrany " "Modified: / 09-02-2018 / 09:44:54 / Jan Vrany " - "Modified (comment): / 19-09-2022 / 23:10:41 / Jan Vrany " + "Modified: / 18-08-2023 / 14:11:27 / Jan Vrany " ! exit @@ -1020,7 +1020,7 @@ self announcer when:GDBEvent do:(handlersArray at:i). ]. handlerFinal := [ :event | connection eventAnnouncerInternal unsubscribe: handlerFinal. blocker signal ]. - blocker := Semaphore new. + blocker := GDBPortlib current newSemaphore. block value. [ (blocker waitWithTimeoutMs:timeout) isNil ifTrue:[ @@ -1044,7 +1044,7 @@ "Created: / 08-03-2015 / 07:28:39 / Jan Vrany " "Modified: / 02-10-2018 / 14:26:16 / Jan Vrany " "Modified (format): / 03-10-2018 / 12:58:30 / Jan Vrany " - "Modified: / 10-09-2021 / 15:41:33 / Jan Vrany " + "Modified: / 18-08-2023 / 14:16:58 / Jan Vrany " ! ! !GDBDebugger methodsFor:'event handling'! diff -r 2d0631d5ed1a -r fdfe1a981363 GDBInternalPipeStream.st --- a/GDBInternalPipeStream.st Fri Aug 18 14:10:59 2023 +0100 +++ b/GDBInternalPipeStream.st Fri Aug 18 14:25:54 2023 +0100 @@ -193,14 +193,15 @@ first := 1. last := 0. - accessLock := Semaphore forMutualExclusion." Plug new respondTo: #critical: with: [ :block | block value ]; yourself." - dataAvailable := Semaphore new. - spaceAvailable := Semaphore new. + accessLock := GDBPortlib current newMutex." Plug new respondTo: #critical: with: [ :block | block value ]; yourself." + dataAvailable := GDBPortlib current newSemaphore. + spaceAvailable := GDBPortlib current newSemaphore. closed := false "Created: / 07-06-2014 / 00:49:41 / Jan Vrany " "Modified: / 11-06-2014 / 23:12:54 / Jan Vrany " + "Modified: / 18-08-2023 / 14:18:17 / Jan Vrany " ! ! !GDBInternalPipeStream methodsFor:'non homogenous reading'! diff -r 2d0631d5ed1a -r fdfe1a981363 GDBPortlib.st --- a/GDBPortlib.st Fri Aug 18 14:10:59 2023 +0100 +++ b/GDBPortlib.st Fri Aug 18 14:25:54 2023 +0100 @@ -146,6 +146,20 @@ ^ NonPositionableExternalStream makePipe ! ! +!GDBPortlib methodsFor:'synchronization'! + +newMutex + ^ Semaphore forMutualExclusion + + "Created: / 18-08-2023 / 14:17:36 / Jan Vrany " +! + +newSemaphore + ^ Semaphore new + + "Created: / 18-08-2023 / 14:16:31 / Jan Vrany " +! ! + !GDBPortlib methodsFor:'user interface'! newCLI: aGDBDebugger diff -r 2d0631d5ed1a -r fdfe1a981363 ports/pharo/src/LibGDBs-Internal-Portlib-Pharo/GDBPortlibPharo.class.st --- a/ports/pharo/src/LibGDBs-Internal-Portlib-Pharo/GDBPortlibPharo.class.st Fri Aug 18 14:10:59 2023 +0100 +++ b/ports/pharo/src/LibGDBs-Internal-Portlib-Pharo/GDBPortlibPharo.class.st Fri Aug 18 14:25:54 2023 +0100 @@ -62,6 +62,14 @@ ] +{ #category : #synchronization } +GDBPortlibPharo >> newMutex [ + ^ Mutex new + + "Created: / 18-08-2023 / 14:17:36 / Jan Vrany " + +] + { #category : #streams } GDBPortlibPharo >> newPTY [ "Allocate a PTY and return it as an instance of GDBPTY"