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