ActiveObject.st
author chzeiher
Tue, 27 Nov 2018 16:31:23 +0100
changeset 4770 ff398f221e71
parent 4300 9d3c61b5d387
child 5010 d1e8ce4f966c
permissions -rw-r--r--
#BUGFIX by chzeiher class: Socket class changed: #getRandomAvailablePortOnHost: bandaid to have the method working remotely. By essentially picking a port at random :S
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2886
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2013 by eXept Software AG
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
4300
9d3c61b5d387 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
    14
"{ NameSpace: Smalltalk }"
9d3c61b5d387 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
    15
2886
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
Object subclass:#ActiveObject
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:'process messageQueue'
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:'AccessLock'
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Kernel-Processes'
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
Message subclass:#MessageAndResponse
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
	instanceVariableNames:'action ok result exception ready'
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
	classVariableNames:''
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
	poolDictionaries:''
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
	privateIn:ActiveObject
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
Lookup subclass:#RedirectingLookup
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
	instanceVariableNames:''
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
	classVariableNames:'Instance'
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
	poolDictionaries:''
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
	privateIn:ActiveObject
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!ActiveObject class methodsFor:'documentation'!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
copyright
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
 COPYRIGHT (c) 2013 by eXept Software AG
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
              All Rights Reserved
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
 This software is furnished under a license and may be used
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
 only in accordance with the terms of that license and with the
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
 inclusion of the above copyright notice.   This software may not
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
 be provided or otherwise made available to, or used by, any
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
 other person.  No title to or ownership of the software is
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
 hereby transferred.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
documentation
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    an active object executes incoming messages in a serialized, synchronous manner,
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    enqueuing incoming messages, executing them one after the other, and returning results to the caller.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    Messages are synchronous: the caller is blocked while I perform my duty.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    Exceptions during execution are sent back to the caller.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    This is an abstract framework class, to be subclassed for real workers.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    The following is a not-yet-working experiment, using lookup objects to redirect automatcally into a synchronizing
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    method. This does not work yet.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    Notice the use of the lookup object here: all incoming messages from a process other than my worker-process
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    itself are forwarded to the #doesNotUnderstand: method. There is no need to inherit from nil, and subclasses can use
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    any messages they like locally, without them being enqueued.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    For now, define methods which have to be synchronized by defining them as:
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
        methodX
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
            self synchronized:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
                ...
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
                do something
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
                ...
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
            ]
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    [Author:]
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
        Claus Gittinger
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
examples
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
  normally, one would subclass ActiveObject and put protocol into it;
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
  here, for the example, an anon Printer is defined. It is slow printing to the Transcript for a demo.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
  The interesting thing is the error handling which is demonstrated in printWithError:
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
  Any exception inside the worker object is returned back and raised in the active-object's client,
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
  not in the worker (take a look at the call-chain, when running the example below).
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    |workerClass worker|
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    workerClass := ActiveObject 
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
                        subclass:#Printer
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
                        instanceVariableNames:''
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
                        classVariableNames:''
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
                        poolDictionaries:''
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
                        category:nil
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
                        inEnvironment:nil.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    workerClass compile:'
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
print:aLine
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    self synchronized:[.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
        aLine do:[:ch |
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
            Transcript show:ch.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
            Delay waitForSeconds:0.2.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
        ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
        Transcript cr.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    ]
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
'.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    workerClass compile:'
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
printWithError:aLine
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    self synchronized:[.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
        aLine do:[:ch |
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
            Transcript show:ch.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
            ch == $l ifTrue:[ self foo ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
            Delay waitForSeconds:0.2.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
        ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
        Transcript cr.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    ]
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
'.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    worker := workerClass new.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    'now ready for printing'.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    worker printWithError:'abcdef'.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    worker printWithError:'hello world'.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
! !
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
!ActiveObject class methodsFor:'initialization'!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
initialize
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    AccessLock := Semaphore forMutualExclusion.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    "/ self lookupObject: RedirectingLookup new
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    self lookupObject: nil
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
! !
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
!ActiveObject class methodsFor:'instance creation'!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
new
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    |newObject|
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    newObject := self basicNew initialize.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    ^  newObject.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
! !
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
!ActiveObject methodsFor:'accessing'!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
process
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    ^ process
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
! !
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
!ActiveObject methodsFor:'message handling'!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
messageHandlingLoop
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    |here|
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    [ true ] whileTrue:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
        |paket|
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
        "/ Transcript showCR:'A: await message...'.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
        (messageQueue readWaitWithTimeoutMs:30000) ifTrue:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
            "/ inactive for 30 seconds - exit
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
            AccessLock critical:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
                messageQueue isEmpty ifTrue:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
                    "/ Transcript showCR:'A: inactive - stop worker'.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
                    process := nil.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
                    messageQueue := nil.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
                ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
            ].
4300
9d3c61b5d387 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
   172
            "exit the worker process loop"
9d3c61b5d387 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
   173
            ^ self
2886
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
        ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
        
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
        paket := messageQueue next.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
        "/ Transcript showCR:'A: got message: ', paket selector.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
        Exception handle:[:ex |
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
             |ex2 c c2|
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
             "create a copy of the sender chain, up to this frame here
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
              (cannot pass the original exception chain, because that one will be unwound, 
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
               thereby clearing the senders)"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
             ex2 := ex shallowCopy.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
             c := ex2 suspendedContext.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
             c2 := c shallowCopy.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
             ex2 suspendedContext: c2.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
             [ c sender ~~ here ] whileTrue:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
                c2 setSender:(c sender shallowCopy).
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
                c2 := c2 sender.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
                c := c sender
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
             ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
             paket ok: false.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
             paket exception: ex2.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
        ] do:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
            |rslt|
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
            here := thisContext.    
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
            rslt := paket action value. "<- here, an exception may occur"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
            paket ok: true.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
            paket result:rslt.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
        ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
        "/ Transcript showCR:'send reply.'.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
        paket ready signal
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
sendAction: aBlock
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    |paket sema k|
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    process isNil ifTrue:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
        AccessLock critical:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
            process isNil ifTrue:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
                "/ Transcript showCR:'starting worker thread'.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
                messageQueue := SharedQueue new.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
                process := [
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
                                [
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
                                    self messageHandlingLoop
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
                                ] ensure:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
                                    process := nil
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
                                ]
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
                           ] fork.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
            ]
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
        ]
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    paket := MessageAndResponse new.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
    paket action: aBlock.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    paket ready: (sema := Semaphore new).
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    messageQueue nextPut: paket.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    sema wait.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    "arrive here, when done with message"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    paket ok ifTrue:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
        ^ paket result
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
    ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
    "/ exception
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    "/ patch the sender chain by tacking my calling chain to the end of the exception chain (from the worker), 
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
    "/ so the debugger shows a picture as if the error happened here
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
    k := paket exception suspendedContext.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    [ k sender notNil ] whileTrue:[ k := k sender ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
    k setSender: thisContext sender sender.  "/ hide sendAction and synchronized frames
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
    paket exception doRaise. "/ reraise, now in my context
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
sendSelector: selector arguments: arguments
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    |paket sema|
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
    process isNil ifTrue:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
        AccessLock critical:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
            process isNil ifTrue:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
                "/ Transcript showCR:'starting worker thread'.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
                messageQueue := SharedQueue new.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
                process := [
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
                                [
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
                                    self messageHandlingLoop
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
                                ] ensure:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
                                    process := nil
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
                                ]
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
                           ] fork.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
            ]
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
        ]
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
    ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
    paket := MessageAndResponse new.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
    paket selector: selector.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
    paket arguments: arguments.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
    paket ready: (sema := Semaphore new).
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
    "/ Transcript showCR:'send message...'.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
    messageQueue nextPut: paket.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
    sema wait.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
    "/ Transcript showCR:'got reply...'.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
    "arrive here, when done with message"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    paket ok ifTrue:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
        ^ paket result
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
    "/ exception
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
    paket exception raiseSignal. "/ reraise, now in my context
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
synchronized:aBlock
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
    Processor activeProcess == process ifTrue:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
        ^ aBlock value
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    ^ self sendAction:aBlock.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
synchronizedMethod
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
    "marks calling methods as being handled via the queue"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
    |retVal|
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
    Processor activeProcess == process ifTrue:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
        ^ self
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
    ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
    retVal := self sendSelector:(thisContext sender selector) arguments:(thisContext sender args).
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
    thisContext sender return:retVal.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
! !
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
!ActiveObject::MessageAndResponse methodsFor:'accessing'!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
action
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
    ^ action
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
action:something
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
    action := something.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
exception
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
    ^ exception
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
exception:something
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
    exception := something.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
ok
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    ^ ok
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
ok:something
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
    ok := something.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
ready
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
    ^ ready
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
ready:something
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
    ready := something.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
result
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
    ^ result
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
result:something
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
    result := something.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
! !
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
!ActiveObject::RedirectingLookup class methodsFor:'instance creation'!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
new
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    Instance isNil ifTrue: [Instance := self basicNew].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
    ^ Instance
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
! !
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
!ActiveObject::RedirectingLookup methodsFor:'lookup'!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
lookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
    "redircet everything into the receiver's doesNotUnderstand method"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
Transcript show:'l '; showCR:aReceiver class name.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
    (aReceiver isNil "fake call from lookupMethodFor: - sigh"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
    or:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
        "insider messages are handled as usual"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
        "to avoid recursive lookup error..."
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
        ((ActiveObject compiledMethodAt:#process) valueWithReceiver: aReceiver arguments:#()) == Processor activeProcess]
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
    ) ifTrue:[
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
        ^  super lookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
    ].
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
    "messages from the outside are forwarded to #doesNotUnderstand:"
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
    ^ aReceiver compiledMethodAt:#doesNotUnderstand.
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
! !
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
!ActiveObject class methodsFor:'documentation'!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
version
4300
9d3c61b5d387 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
   375
    ^ '$Header$'
2886
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
!
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
version_CVS
4300
9d3c61b5d387 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
   379
    ^ '$Header$'
2886
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
! !
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
e0e5b1d68946 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
ActiveObject initialize!