SemaphoreMonitor.st
changeset 984 8279e48ebdcb
parent 982 ed5de0e2fb24
child 993 db983895f7c3
equal deleted inserted replaced
983:e02eaa70dbd7 984:8279e48ebdcb
    65 ! !
    65 ! !
    66 
    66 
    67 !SemaphoreMonitor methodsFor:'drawing'!
    67 !SemaphoreMonitor methodsFor:'drawing'!
    68 
    68 
    69 titleLine
    69 titleLine
    70     ^ 'id   count  waiting process(es)                   '.
    70     ^ ' id     name    count  waiting process(es)                   '.
    71 
    71 
    72     "
    72     "
    73      SemaphoreMonitor open
    73      SemaphoreMonitor open
    74     "
    74     "
    75 
    75 
    76     "Modified: 23.1.1997 / 03:04:27 / cg"
    76     "Modified: 23.1.1997 / 04:07:54 / cg"
    77 !
    77 !
    78 
    78 
    79 updateList
    79 updateList
    80     "update list of semaphores"
    80     "update list of semaphores"
    81 
    81 
    82     |newList|
    82     |newList|
    83 
    83 
    84     shown ifTrue:[
    84     shown ifTrue:[
    85         newList := Semaphore allInstances.
    85         newList := Semaphore allSubInstances.
    86 
    86 
    87         "sort by hashKey - will not always generate unique numbers,
    87         "sort by hashKey - will not always generate unique numbers,
    88          but most of the time, this works ... for now"
    88          but most of the time, this works ... for now"
    89 
    89 
    90         newList sort:[:s1 :s2 | s1 identityHash < s2 identityHash].
    90         newList sort:[:s1 :s2 | s1 identityHash < s2 identityHash].
    99         Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay
    99         Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay
   100     ].
   100     ].
   101 
   101 
   102     "Modified: 3.7.1996 / 13:37:29 / stefan"
   102     "Modified: 3.7.1996 / 13:37:29 / stefan"
   103     "Created: 23.1.1997 / 02:44:48 / cg"
   103     "Created: 23.1.1997 / 02:44:48 / cg"
   104     "Modified: 23.1.1997 / 02:57:49 / cg"
   104     "Modified: 23.1.1997 / 04:10:22 / cg"
   105 !
   105 !
   106 
   106 
   107 updateStatus
   107 updateStatus
   108     "update status display of semaphores"
   108     "update status display of semaphores"
   109 
   109 
   116             list := OrderedCollection new:(semaphores size + 2).
   116             list := OrderedCollection new:(semaphores size + 2).
   117             list add:self titleLine.
   117             list add:self titleLine.
   118             list add:(String new:self titleLine size withAll:$-).
   118             list add:(String new:self titleLine size withAll:$-).
   119 
   119 
   120             semaphores validElementsDo:[:aSemaphore |
   120             semaphores validElementsDo:[:aSemaphore |
   121                 |waiters waitersNames id str|
   121                 |waiters waitersNames nm id str|
   122 
   122 
   123                 waiters := aSemaphore waitingProcesses.
   123                 waiters := aSemaphore waitingProcesses.
   124 
   124 
   125                 str := '' writeStream.
   125                 str := '' writeStream.
   126                 str writeLimit:80.
   126                 str writeLimit:80.
   132                         str space.
   132                         str space.
   133                     ].
   133                     ].
   134                 ].
   134                 ].
   135                 waitersNames := str contents.
   135                 waitersNames := str contents.
   136 
   136 
       
   137                 (aSemaphore respondsTo:#name) ifTrue:[
       
   138                     nm := aSemaphore name.
       
   139                 ] ifFalse:[
       
   140                     nm := ''
       
   141                 ].
   137                 id := aSemaphore identityHash bitShift:-12.
   142                 id := aSemaphore identityHash bitShift:-12.
   138                 list add:((id printStringPaddedTo:6)
   143                 list add:(
   139                           , ' '
   144                           (id printStringPaddedTo:6)
   140                           , aSemaphore count printString
   145                           , ' '
   141                           , '    '
   146                           , ((nm contractTo:10) paddedTo:10)
       
   147                           , ' '
       
   148                           , (aSemaphore count printString paddedTo:3)
       
   149                           , ' '
   142                           , (waiters size printStringPaddedTo:3)
   150                           , (waiters size printStringPaddedTo:3)
   143                           , ' '
   151                           , ' '
   144                           , waitersNames).
   152                           , waitersNames).
   145 
   153 
   146             ].
   154             ].
   164         Processor removeTimedBlock:updateBlock.
   172         Processor removeTimedBlock:updateBlock.
   165         Processor addTimedBlock:updateBlock afterSeconds:updateDelay
   173         Processor addTimedBlock:updateBlock afterSeconds:updateDelay
   166     ]
   174     ]
   167 
   175 
   168     "Modified: 3.7.1996 / 13:56:01 / stefan"
   176     "Modified: 3.7.1996 / 13:56:01 / stefan"
   169     "Modified: 23.1.1997 / 03:02:43 / cg"
   177     "Modified: 23.1.1997 / 04:02:25 / cg"
   170 ! !
   178 ! !
   171 
   179 
   172 !SemaphoreMonitor methodsFor:'menu'!
   180 !SemaphoreMonitor methodsFor:'menu'!
   173 
   181 
   174 inspectSelection
   182 inspectSelection
   281 ! !
   289 ! !
   282 
   290 
   283 !SemaphoreMonitor class methodsFor:'documentation'!
   291 !SemaphoreMonitor class methodsFor:'documentation'!
   284 
   292 
   285 version
   293 version
   286     ^ '$Header: /cvs/stx/stx/libtool/SemaphoreMonitor.st,v 1.2 1997-01-23 02:29:24 cg Exp $'
   294     ^ '$Header: /cvs/stx/stx/libtool/SemaphoreMonitor.st,v 1.3 1997-01-23 03:10:54 cg Exp $'
   287 ! !
   295 ! !