smalltalk
/
osmo-st-core
Archived
1
0
Fork 0

dispatcher: Merge code from Norbert to allow to install alternative dispatchers

Norbert introduced the MockDispatcher to get nice and direct
exceptions.
This commit is contained in:
Holger Hans Peter Freyther 2014-07-27 10:48:51 +02:00
parent f2be904848
commit c5f53b7d64
1 changed files with 19 additions and 3 deletions

View File

@ -28,13 +28,24 @@ Object subclass: Dispatcher [
Dispatcher class >> new [
<category: 'private'>
^ super new
initialize;
^super new
addToBeFinalized;
startDispatching;
yourself
]
initialize [
Dispatcher class >> install [
<category: 'singleton'>
| dispatcher |
dispatcher := Smalltalk at: #OsmoDispatcher ifAbsentPut: [self new].
^dispatcher class = self
ifTrue: [dispatcher]
ifFalse: [
dispatcher terminate.
Smalltalk at: #OsmoDispatcher put: self new]
]
startDispatching [
<category: 'private'>
quit := false.
queue := SharedQueue new.
@ -66,6 +77,11 @@ Object subclass: Dispatcher [
sem wait.
]
terminate [
<category: 'private'>
dispatch terminate
]
]
Eval [