Future.st
changeset 4814 62adbb76ba99
parent 4574 8e32161e5056
child 5031 0cfe45b14c1a
equal deleted inserted replaced
4813:f53aac0fa76c 4814:62adbb76ba99
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  This is a Manchester Goodie protected by copyright.
     4  This is a Manchester Goodie protected by copyright.
     3  These conditions are imposed on the whole Goodie, and on any significant
     5  These conditions are imposed on the whole Goodie, and on any significant
     4  part of it which is separately transmitted or stored:
     6  part of it which is separately transmitted or stored:
     5 	* You must ensure that every copy includes this notice, and that
     7 	* You must ensure that every copy includes this notice, and that
   173      ensure that any messages sent to me before execution
   175      ensure that any messages sent to me before execution
   174      of the block has terminated are suspended until it has terminated."
   176      of the block has terminated are suspended until it has terminated."
   175 
   177 
   176     semaphore := Semaphore name:'Future'.
   178     semaphore := Semaphore name:'Future'.
   177     [
   179     [
   178         [result := aBlock value] ensure:[semaphore signal. semaphore := nil.]
   180         result := [aBlock value] ensure:[semaphore signal. semaphore := nil.]
   179     ] fork
   181     ] fork
   180 
   182 
   181     "Modified: / 09-08-2017 / 11:54:19 / cg"
   183     "Modified: / 09-08-2017 / 11:54:19 / cg"
       
   184     "Modified: / 12-02-2019 / 20:26:39 / Stefan Vogel"
   182 !
   185 !
   183 
   186 
   184 block:aBlock value:aValue
   187 block:aBlock value:aValue
   185     "Execute aBlock in parallel with whatever called me, but
   188     "Execute aBlock in parallel with whatever called me, but
   186      ensure that any messages sent to me before execution
   189      ensure that any messages sent to me before execution
   187      of the block has terminated are suspended until it has terminated."
   190      of the block has terminated are suspended until it has terminated."
   188 
   191 
   189     semaphore := Semaphore name:'Future'.
   192     semaphore := Semaphore name:'Future'.
   190     [
   193     [
   191         [
   194         result := [aBlock value:aValue] ensure:[semaphore signal. semaphore := nil.]
   192             result := aBlock value:aValue
       
   193         ] ensure:[semaphore signal. semaphore := nil.]
       
   194     ] fork
   195     ] fork
   195 
   196 
   196     "Modified: / 09-08-2017 / 11:54:23 / cg"
   197     "Modified: / 09-08-2017 / 11:54:23 / cg"
       
   198     "Modified: / 12-02-2019 / 20:27:03 / Stefan Vogel"
   197 !
   199 !
   198 
   200 
   199 block:aBlock value:value1 value:value2
   201 block:aBlock value:value1 value:value2
   200     "Execute aBlock in parallel with whatever called me, but
   202     "Execute aBlock in parallel with whatever called me, but
   201      ensure that any messages sent to me before execution
   203      ensure that any messages sent to me before execution
   202      of the block has terminated are suspended until it has terminated."
   204      of the block has terminated are suspended until it has terminated."
   203 
   205 
   204     semaphore := Semaphore name:'Future'.
   206     semaphore := Semaphore name:'Future'.
   205     [
   207     [
   206         [
   208         result := [
   207             result := aBlock value:value1 value:value2
   209             aBlock value:value1 value:value2
   208         ] ensure:[semaphore signal. semaphore := nil.]
   210         ] ensure:[semaphore signal. semaphore := nil.]
   209     ] fork
   211     ] fork
   210 
   212 
   211     "Modified: / 09-08-2017 / 11:54:27 / cg"
   213     "Modified: / 09-08-2017 / 11:54:27 / cg"
       
   214     "Modified: / 12-02-2019 / 20:27:20 / Stefan Vogel"
   212 !
   215 !
   213 
   216 
   214 block:aBlock value:value1 value:value2 value:value3
   217 block:aBlock value:value1 value:value2 value:value3
   215     "Execute aBlock in parallel with whatever called me, but
   218     "Execute aBlock in parallel with whatever called me, but
   216      ensure that any messages sent to me before execution
   219      ensure that any messages sent to me before execution
   217      of the block has terminated are suspended until it has terminated."
   220      of the block has terminated are suspended until it has terminated."
   218 
   221 
   219     semaphore := Semaphore name:'Future'.
   222     semaphore := Semaphore name:'Future'.
   220     [
   223     [
   221         [
   224         result := [
   222             result := aBlock value:value1 value:value2 value:value3
   225             aBlock value:value1 value:value2 value:value3
   223         ] ensure:[semaphore signal. semaphore := nil.]
   226         ] ensure:[semaphore signal. semaphore := nil.]
   224     ] fork
   227     ] fork
   225 
   228 
   226     "Modified: / 09-08-2017 / 11:54:31 / cg"
   229     "Modified: / 09-08-2017 / 11:54:31 / cg"
       
   230     "Modified: / 12-02-2019 / 20:27:31 / Stefan Vogel"
   227 !
   231 !
   228 
   232 
   229 block:aBlock valueWithArguments:anArray
   233 block:aBlock valueWithArguments:anArray
   230     "Execute aBlock in parallel with whatever called me, but
   234     "Execute aBlock in parallel with whatever called me, but
   231      ensure that any messages sent to me before execution
   235      ensure that any messages sent to me before execution
   232      of the block has terminated are suspended until it has terminated."
   236      of the block has terminated are suspended until it has terminated."
   233 
   237 
   234     semaphore := Semaphore name:'Future'.
   238     semaphore := Semaphore name:'Future'.
   235     [
   239     [
   236         [
   240         result := [
   237             result := aBlock valueWithArguments:anArray
   241             aBlock valueWithArguments:anArray
   238         ] ensure:[semaphore signal. semaphore := nil.]
   242         ] ensure:[semaphore signal. semaphore := nil.]
   239     ] fork
   243     ] fork
   240 
   244 
   241     "Modified: / 09-08-2017 / 11:54:34 / cg"
   245     "Modified: / 09-08-2017 / 11:54:34 / cg"
       
   246     "Modified: / 12-02-2019 / 20:27:40 / Stefan Vogel"
   242 !
   247 !
   243 
   248 
   244 priority:prio block: aBlock
   249 priority:prio block: aBlock
   245     "Execute aBlock in parallel with whatever called me, but
   250     "Execute aBlock in parallel with whatever called me, but
   246      ensure that any messages sent to me before execution
   251      ensure that any messages sent to me before execution
   247      of the block has terminated are suspended until it has terminated."
   252      of the block has terminated are suspended until it has terminated."
   248 
   253 
   249     semaphore := Semaphore name:'Future'.
   254     semaphore := Semaphore name:'Future'.
   250     [
   255     [
   251         [result := aBlock value] ensure:[semaphore signal. semaphore := nil.]
   256         result := [aBlock value] ensure:[semaphore signal. semaphore := nil.]
   252     ] forkAt:prio
   257     ] forkAt:prio
   253 
   258 
   254     "Created: / 04-10-2011 / 14:53:21 / cg"
   259     "Created: / 04-10-2011 / 14:53:21 / cg"
   255     "Modified: / 09-08-2017 / 11:54:38 / cg"
   260     "Modified: / 09-08-2017 / 11:54:38 / cg"
       
   261     "Modified: / 12-02-2019 / 20:27:52 / Stefan Vogel"
   256 !
   262 !
   257 
   263 
   258 priority:prio block: aBlock value: aValue
   264 priority:prio block: aBlock value: aValue
   259     "Execute aBlock in parallel with whatever called me, but
   265     "Execute aBlock in parallel with whatever called me, but
   260      ensure that any messages sent to me before execution
   266      ensure that any messages sent to me before execution
   261      of the block has terminated are suspended until it has terminated."
   267      of the block has terminated are suspended until it has terminated."
   262 
   268 
   263     semaphore := Semaphore name:'Future'.
   269     semaphore := Semaphore name:'Future'.
   264     [
   270     [
   265         [
   271         result := [
   266             result := aBlock value:aValue
   272             aBlock value:aValue
   267         ] ensure:[semaphore signal. semaphore := nil.]
   273         ] ensure:[semaphore signal. semaphore := nil.]
   268     ] forkAt:prio
   274     ] forkAt:prio
   269 
   275 
   270     "Created: / 04-10-2011 / 14:53:35 / cg"
   276     "Created: / 04-10-2011 / 14:53:35 / cg"
   271     "Modified: / 09-08-2017 / 11:54:41 / cg"
   277     "Modified: / 09-08-2017 / 11:54:41 / cg"
       
   278     "Modified: / 12-02-2019 / 20:28:02 / Stefan Vogel"
   272 !
   279 !
   273 
   280 
   274 priority:prio block:aBlock value:value1 value:value2
   281 priority:prio block:aBlock value:value1 value:value2
   275     "Execute aBlock in parallel with whatever called me, but
   282     "Execute aBlock in parallel with whatever called me, but
   276      ensure that any messages sent to me before execution
   283      ensure that any messages sent to me before execution
   277      of the block has terminated are suspended until it has terminated."
   284      of the block has terminated are suspended until it has terminated."
   278 
   285 
   279     semaphore := Semaphore name:'Future'.
   286     semaphore := Semaphore name:'Future'.
   280     [
   287     [
   281         [
   288         result := [
   282             result := aBlock value:value1 value:value2
   289             aBlock value:value1 value:value2
   283         ] ensure:[semaphore signal. semaphore := nil.]
   290         ] ensure:[semaphore signal. semaphore := nil.]
   284     ] forkAt:prio
   291     ] forkAt:prio
   285 
   292 
   286     "Created: / 04-10-2011 / 14:54:03 / cg"
   293     "Created: / 04-10-2011 / 14:54:03 / cg"
   287     "Modified: / 09-08-2017 / 11:54:44 / cg"
   294     "Modified: / 09-08-2017 / 11:54:44 / cg"
       
   295     "Modified: / 12-02-2019 / 20:28:10 / Stefan Vogel"
   288 !
   296 !
   289 
   297 
   290 priority:prio block:aBlock value:value1 value:value2 value:value3
   298 priority:prio block:aBlock value:value1 value:value2 value:value3
   291     "Execute aBlock in parallel with whatever called me, but
   299     "Execute aBlock in parallel with whatever called me, but
   292      ensure that any messages sent to me before execution
   300      ensure that any messages sent to me before execution
   293      of the block has terminated are suspended until it has terminated."
   301      of the block has terminated are suspended until it has terminated."
   294 
   302 
   295     semaphore := Semaphore name:'Future'.
   303     semaphore := Semaphore name:'Future'.
   296     [
   304     [
   297         [
   305         result := [
   298             result := aBlock value:value1 value:value2 value:value3
   306             aBlock value:value1 value:value2 value:value3
   299         ] ensure:[semaphore signal. semaphore := nil.]
   307         ] ensure:[semaphore signal. semaphore := nil.]
   300     ] forkAt:prio
   308     ] forkAt:prio
   301 
   309 
   302     "Created: / 04-10-2011 / 14:54:51 / cg"
   310     "Created: / 04-10-2011 / 14:54:51 / cg"
   303     "Modified: / 09-08-2017 / 11:54:47 / cg"
   311     "Modified: / 09-08-2017 / 11:54:47 / cg"
       
   312     "Modified: / 12-02-2019 / 20:28:21 / Stefan Vogel"
   304 !
   313 !
   305 
   314 
   306 priority:prio block:aBlock valueWithArguments:anArray
   315 priority:prio block:aBlock valueWithArguments:anArray
   307     "Execute aBlock in parallel with whatever called me, but
   316     "Execute aBlock in parallel with whatever called me, but
   308      ensure that any messages sent to me before execution
   317      ensure that any messages sent to me before execution
   309      of the block has terminated are suspended until it has terminated."
   318      of the block has terminated are suspended until it has terminated."
   310 
   319 
   311     semaphore := Semaphore name:'Future'.
   320     semaphore := Semaphore name:'Future'.
   312     [
   321     [
   313         [
   322         result := [
   314             result := aBlock valueWithArguments:anArray
   323             aBlock valueWithArguments:anArray
   315         ] ensure:[semaphore signal. semaphore := nil.]
   324         ] ensure:[semaphore signal. semaphore := nil.]
   316     ] forkAt:prio
   325     ] forkAt:prio
   317 
   326 
   318     "Created: / 04-10-2011 / 14:55:14 / cg"
   327     "Created: / 04-10-2011 / 14:55:14 / cg"
   319     "Modified: / 09-08-2017 / 11:54:50 / cg"
   328     "Modified: / 09-08-2017 / 11:54:50 / cg"
       
   329     "Modified: / 12-02-2019 / 20:28:30 / Stefan Vogel"
   320 ! !
   330 ! !
   321 
   331 
   322 !Future methodsFor:'printing'!
   332 !Future methodsFor:'printing'!
   323 
   333 
   324 displayOn:aGCOrStream
   334 displayOn:aGCOrStream