Lazy.st
author Claus Gittinger <cg@exept.de>
Thu, 09 Jun 2016 17:01:18 +0200
changeset 3918 c565bdb0c8c4
parent 3849 62f298788374
child 3977 e913680689bf
permissions -rw-r--r--
#OTHER by cg class: LinkedList changed: #at:ifAbsent:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
     1
"
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
     2
 This is a Manchester Goodie protected by copyright.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
     3
 These conditions are imposed on the whole Goodie, and on any significant
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
     4
 part of it which is separately transmitted or stored:
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
     5
	* You must ensure that every copy includes this notice, and that
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
     6
	  source and author(s) of the material are acknowledged.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
     7
	* These conditions must be imposed on anyone who receives a copy.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
     8
	* The material shall not be used for commercial gain without the prior
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
     9
	  written consent of the author(s).
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    10
 Further information on the copyright conditions may be obtained by
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    11
 sending electronic mail:
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    12
	To: goodies-lib@cs.man.ac.uk
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    13
	Subject: copyright
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    14
 or by writing to The Smalltalk Goodies Library Manager, Dept of
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    15
 Computer Science, The University, Manchester M13 9PL, UK
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    16
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    17
 (C) Copyright 1992 University of Manchester
2341
36e455705ee6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
    18
 For more information about the Manchester Goodies Library (from which
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    19
 this file was distributed) send e-mail:
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    20
	To: goodies-lib@cs.man.ac.uk
2341
36e455705ee6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
    21
	Subject: help
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    22
"
2341
36e455705ee6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
    23
"{ Package: 'stx:libbasic2' }"
457
c862c91716b6 packages
Claus Gittinger <cg@exept.de>
parents: 351
diff changeset
    24
3849
62f298788374 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3063
diff changeset
    25
"{ NameSpace: Smalltalk }"
62f298788374 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3063
diff changeset
    26
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    27
ProtoObject subclass:#Lazy
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    28
	instanceVariableNames:'result startSemaphore endSemaphore'
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    29
	classVariableNames:''
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    30
	poolDictionaries:''
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    31
	category:'Kernel-Processes'
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    32
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    33
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    34
!Lazy class methodsFor:'documentation'!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    35
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    36
copyright
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    37
"
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    38
 This is a Manchester Goodie protected by copyright.
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    39
 These conditions are imposed on the whole Goodie, and on any significant
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    40
 part of it which is separately transmitted or stored:
67
6d8a403eff0a *** empty log message ***
claus
parents: 62
diff changeset
    41
	* You must ensure that every copy includes this notice, and that
6d8a403eff0a *** empty log message ***
claus
parents: 62
diff changeset
    42
	  source and author(s) of the material are acknowledged.
6d8a403eff0a *** empty log message ***
claus
parents: 62
diff changeset
    43
	* These conditions must be imposed on anyone who receives a copy.
6d8a403eff0a *** empty log message ***
claus
parents: 62
diff changeset
    44
	* The material shall not be used for commercial gain without the prior
6d8a403eff0a *** empty log message ***
claus
parents: 62
diff changeset
    45
	  written consent of the author(s).
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    46
 Further information on the copyright conditions may be obtained by
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    47
 sending electronic mail:
67
6d8a403eff0a *** empty log message ***
claus
parents: 62
diff changeset
    48
	To: goodies-lib@cs.man.ac.uk
6d8a403eff0a *** empty log message ***
claus
parents: 62
diff changeset
    49
	Subject: copyright
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    50
 or by writing to The Smalltalk Goodies Library Manager, Dept of
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    51
 Computer Science, The University, Manchester M13 9PL, UK
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    52
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    53
 (C) Copyright 1992 University of Manchester
2341
36e455705ee6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
    54
 For more information about the Manchester Goodies Library (from which
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    55
 this file was distributed) send e-mail:
67
6d8a403eff0a *** empty log message ***
claus
parents: 62
diff changeset
    56
	To: goodies-lib@cs.man.ac.uk
2341
36e455705ee6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
    57
	Subject: help
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    58
"
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    59
!
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    60
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    61
documentation
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    62
"
3063
b4af2ee4ed93 class: Lazy
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
    63
    I represent an execution which may or may not be required.
2341
36e455705ee6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
    64
    I will not start execution until at least one message has been received.
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    65
    The messages sent to me are delayed until execution has completed.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    66
2341
36e455705ee6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
    67
    [author:]
3063
b4af2ee4ed93 class: Lazy
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
    68
        tph@cs.man.ac.uk
1515
006cd21bbc25 Inherit from ProtoObject.
Stefan Vogel <sv@exept.de>
parents: 1326
diff changeset
    69
006cd21bbc25 Inherit from ProtoObject.
Stefan Vogel <sv@exept.de>
parents: 1326
diff changeset
    70
    [see also:]
3063
b4af2ee4ed93 class: Lazy
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
    71
        Block LazyValue Future
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    72
"
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    73
!
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    74
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    75
examples
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    76
"
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    77
  Evaluates the factorial, starting only when the
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    78
  result is actually required (when printString is sent).
2341
36e455705ee6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
    79
						[exBegin]
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    80
    | fac |
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    81
    fac := [100 factorial] lazyValue.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    82
    Transcript showCR: 'Doing nothing. '.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    83
    (Delay forSeconds: 2) wait.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    84
    Transcript showCR: fac printString.
2341
36e455705ee6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
    85
						[exEnd]
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    86
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    87
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    88
  Starts evaluating both factorials only when required (by the touch),
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    89
  and waits until both blocks have finished before continuing.
2341
36e455705ee6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
    90
						[exBegin]
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    91
    | fac1 fac2 |
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    92
    fac1 := [Transcript showCR: 'Starting fac1.. '. 100 factorial] lazyValue.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    93
    fac2 := [Transcript showCR: 'Starting fac2.. '. 120 factorial] lazyValue.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    94
    fac2 touch.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    95
    fac1 touch.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    96
    Transcript showCR: 'both completed.'.
2341
36e455705ee6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
    97
						[exEnd]
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    98
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
    99
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   100
  Demonstrates how to pass arguments to a lazy evaluation block.
2341
36e455705ee6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
   101
						[exBegin]
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   102
    | temp |
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   103
    temp := [:x :y :z | x * y * z] lazyValueWithArguments: #(2 3 4).
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   104
    Transcript  showCR: temp printString.
2341
36e455705ee6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
   105
						[exEnd]
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   106
"
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   107
! !
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   108
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   109
!Lazy methodsFor:'evaluating'!
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   110
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   111
block: aBlock
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   112
	"Execute aBlock in parallel, but ensure that any messages sent
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   113
	 to me before execution of the block has terminated are
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   114
	 suspended until it has terminated. Do not start the evaluation
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   115
	 until at least one message has been sent to the receiver."
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   116
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   117
	startSemaphore := Semaphore new.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   118
	endSemaphore := Semaphore new.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   119
	[startSemaphore wait.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   120
	 result := aBlock value.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   121
	 endSemaphore signal] fork
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   122
!
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   123
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   124
block: aBlock value: aValue
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   125
	"Execute aBlock in parallel, but ensure that any messages sent
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   126
	 to me before execution of the block has terminated are
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   127
	 suspended until it has terminated. Do not start the evaluation
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   128
	 until at least one message has been sent to the receiver."
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   129
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   130
	startSemaphore := Semaphore new.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   131
	endSemaphore := Semaphore new.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   132
	[startSemaphore wait.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   133
	 result := aBlock value: aValue.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   134
	 endSemaphore signal] fork
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   135
!
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   136
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   137
block: aBlock value: value1 value: value2
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   138
	"Execute aBlock in parallel, but ensure that any messages sent
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   139
	 to me before execution of the block has terminated are
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   140
	 suspended until it has terminated. Do not start the evaluation
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   141
	 until at least one message has been sent to the receiver."
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   142
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   143
	startSemaphore := Semaphore new.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   144
	endSemaphore := Semaphore new.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   145
	[startSemaphore wait.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   146
	 result := aBlock value: value1 value: value2.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   147
	 endSemaphore signal] fork
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   148
!
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   149
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   150
block: aBlock value: value1 value: value2 value: value3
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   151
	"Execute aBlock in parallel, but ensure that any messages sent
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   152
	 to me before execution of the block has terminated are
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   153
	 suspended until it has terminated. Do not start the evaluation
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   154
	 until at least one message has been sent to the receiver."
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   155
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   156
	startSemaphore := Semaphore new.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   157
	endSemaphore := Semaphore new.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   158
	[startSemaphore wait.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   159
	 result := aBlock value: value1 value: value2 value: value3.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   160
	 endSemaphore signal] fork
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   161
!
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   162
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   163
block: aBlock valueWithArguments: anArray
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   164
	"Execute aBlock in parallel, but ensure that any messages sent
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   165
	 to me before execution of the block has terminated are
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   166
	 suspended until it has terminated. Do not start the evaluation
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   167
	 until at least one message has been sent to the receiver."
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   168
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   169
	startSemaphore := Semaphore new.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   170
	endSemaphore := Semaphore new.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   171
	[startSemaphore wait.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   172
	 result := aBlock valueWithArguments: anArray.
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   173
	 endSemaphore signal] fork
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   174
! !
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   175
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   176
!Lazy methodsFor:'synchronising'!
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   177
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   178
doesNotUnderstand: aMessage
3849
62f298788374 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3063
diff changeset
   179
    "Any message to a Lazy will end up here."
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   180
3849
62f298788374 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3063
diff changeset
   181
    startSemaphore signal.          "Start the evaluation."
62f298788374 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3063
diff changeset
   182
    endSemaphore waitUncounted.     "Wait until evaluation completed."
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   183
3849
62f298788374 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3063
diff changeset
   184
    ^ aMessage sendTo:result
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   185
! !
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   186
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   187
!Lazy methodsFor:'testing'!
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   188
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   189
isLazyValue
2341
36e455705ee6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
   190
    ^ endSemaphore wouldBlock
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   191
! !
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   192
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   193
!Lazy class methodsFor:'documentation'!
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   194
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   195
version
3849
62f298788374 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3063
diff changeset
   196
    ^ '$Header$'
1326
b8e168f120ce comments
Claus Gittinger <cg@exept.de>
parents: 885
diff changeset
   197
! !
3063
b4af2ee4ed93 class: Lazy
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
   198