Promise.st
changeset 1307 18bf29731638
parent 485 fe9c2ff10461
child 1488 6b394aed47f7
equal deleted inserted replaced
1306:4a4a9956b22e 1307:18bf29731638
     1 "
     1 "
     2  COPYRIGHT (c) 1995 by Claus Gittinger
     2  COPYRIGHT (c) 1993 by Claus Gittinger
     3 	      All Rights Reserved
     3 	      All Rights Reserved
     4 
     4 
     5  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
     6  only in accordance with the terms of that license and with the
     6  only in accordance with the terms of that license and with the
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 'From Smalltalk/X, Version:2.10.5 on 29-apr-1995 at 2:28:49 am'!
    13 "{ Package: 'stx:libbasic2' }"
    14 
    14 
    15 Object subclass:#Promise
    15 Object subclass:#Promise
    16 	 instanceVariableNames:'value valueAvailable exception'
    16 	instanceVariableNames:'value valueAvailable exception'
    17 	 classVariableNames:''
    17 	classVariableNames:''
    18 	 poolDictionaries:''
    18 	poolDictionaries:''
    19 	 category:'Kernel-Processes'
    19 	category:'Kernel-Processes'
    20 !
    20 !
    21 
    21 
    22 !Promise class methodsFor:'documentation'!
    22 !Promise class methodsFor:'documentation'!
    23 
    23 
    24 copyright
    24 copyright
    33  other person.  No title to or ownership of the software is
    33  other person.  No title to or ownership of the software is
    34  hereby transferred.
    34  hereby transferred.
    35 "
    35 "
    36 !
    36 !
    37 
    37 
    38 version
       
    39     ^ '$Header: /cvs/stx/stx/libbasic2/Promise.st,v 1.7 1997-01-24 22:19:39 cg Exp $'
       
    40 !
       
    41 
       
    42 documentation
    38 documentation
    43 "
    39 "
    44     When created, a promise will start to evaluate its block in the background,
    40     When created, a promise will start to evaluate its block in the background,
    45     and promise to deliver the value of this computation, when asked
    41     and promise to deliver the value of this computation, when asked
    46     for it via #value. Promises can be used for background computations,
    42     for it via #value. Promises can be used for background computations,
    51 "
    47 "
    52 ! !
    48 ! !
    53 
    49 
    54 !Promise class methodsFor:'instance creation'!
    50 !Promise class methodsFor:'instance creation'!
    55 
    51 
       
    52 value:aBlock
       
    53     "create and return a Promise to evaluate aBlock at the current priority"
       
    54 
       
    55     ^ self new value:aBlock priority:Processor activePriority 
       
    56 !
       
    57 
    56 value:aBlock priority:aPrio
    58 value:aBlock priority:aPrio
    57     "create and return a Promise to evaluate aBlock at some priority"
    59     "create and return a Promise to evaluate aBlock at some priority"
    58 
    60 
    59     ^ self new value:aBlock priority:aPrio
    61     ^ self new value:aBlock priority:aPrio
    60 !
       
    61 
       
    62 value:aBlock
       
    63     "create and return a Promise to evaluate aBlock at the current priority"
       
    64 
       
    65     ^ self new value:aBlock priority:Processor activePriority 
       
    66 ! !
    62 ! !
    67 
    63 
    68 !Promise methodsFor:'accessing'!
    64 !Promise methodsFor:'accessing'!
    69 
    65 
    70 value
    66 value
   117      (i.e. if sending #value to it would NOT block)"
   113      (i.e. if sending #value to it would NOT block)"
   118 
   114 
   119     ^ valueAvailable wouldBlock not
   115     ^ valueAvailable wouldBlock not
   120 ! !
   116 ! !
   121 
   117 
       
   118 !Promise class methodsFor:'documentation'!
       
   119 
       
   120 version
       
   121     ^ '$Header: /cvs/stx/stx/libbasic2/Promise.st,v 1.8 2003-08-29 19:23:33 cg Exp $'
       
   122 ! !