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