More work on events and parsing.
"{ Package: 'jv:libgdbs' }"
Object subclass:#GDBMIDriver
instanceVariableNames:'pid commandChannel commandQueue commandQueueLock
commandDispatcher eventChannel eventQueue eventQueueLock
eventNotifier eventDispatcher'
classVariableNames:''
poolDictionaries:''
category:'GDB-Private'
!
!GDBMIDriver class methodsFor:'instance creation'!
pid:pidArg input:inputArg output:outputArg
^ self new
initializeWithPid:pidArg
input:inputArg
output:outputArg
"Created: / 26-05-2014 / 13:35:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GDBMIDriver methodsFor:'event dispatching'!
eventDispatchLoop
[ pid notNil ] whileTrue:[
self eventDispatchSingle.
].
"Created: / 28-05-2014 / 00:54:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
eventDispatchSingle
"Reads a single event from an event channel and dispatches it"
^ eventChannel nextLine.
"Created: / 28-05-2014 / 00:56:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GDBMIDriver methodsFor:'initialize & release'!
initializeWithPid:pidArg input:inputArg output:outputArg
pid := pidArg.
commandChannel := inputArg.
commandQueue := OrderedCollection new.
commandQueueLock := RecursionLock new.
eventChannel := outputArg.
eventQueue := OrderedCollection new.
eventQueueLock := RecursionLock new.
eventNotifier := Semaphore new.
eventDispatcher := [ self eventDispatchLoop ] newProcess.
eventDispatcher priority: Processor userBackgroundPriority.
eventDispatcher resume.
"Created: / 26-05-2014 / 13:35:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 28-05-2014 / 00:54:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
release
pid notNil ifTrue:[
OperatingSystem sendSignal:(OperatingSystem sigKILL) to:pid.
]
"Created: / 26-05-2014 / 21:30:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
released: status
pid := nil.
commandChannel notNil ifTrue:[
commandChannel close.
commandChannel := nil.
].
eventChannel notNil ifTrue:[
eventChannel close.
eventChannel := nil.
].
"Created: / 26-05-2014 / 21:31:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 27-05-2014 / 10:21:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GDBMIDriver class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
! !