"Changes in change set tfib"! "| s n | s := String new writeStream. s cr. n := 14. #(tfib1 tfib2 tfib3) do: [:functionName| | milliseconds result | milliseconds := Time millisecondsToRun: [result := n perform: functionName]. s cr; nextPutAll: functionName; nextPutAll: ' = '; print: result; nextPutAll: ' in '; print: milliseconds / 1000.0; cr]. s contents ' tfib1 = 610 in 0.066 tfib2 = 610 in 0.037 tfib3 = 610 in 0.045 '"! 'From VisualWorks®, Release 5i.2 of June 8, 2000 on June 23, 2000 at 6:31:26 pm'! Process subclass: #JoinableProcess instanceVariableNames: 'result sync ' classVariableNames: '' poolDictionaries: '' category: 'Kernel-Processes'! !BlockClosure methodsFor: 'scheduling'! forkForJoin "Create and schedule a process running the code in the receiver. Answer the new process." | forkedProcess | forkedProcess := JoinableProcess forBlock: self priority: Processor activePriority. forkedProcess resume. ^forkedProcess! ! !Integer methodsFor: 'mathematical functions'! tfib1 | r | ^self < 2 ifTrue: [1] ifFalse: [r := [(self - 2) tfib1] promise. (self - 1) tfib1 + r value]! tfib2 | s r1 r2 | ^self < 2 ifTrue: [1] ifFalse: [s := Semaphore new. [r1 := (self - 2) tfib2. s signal] fork. r2 := (self - 1) tfib2. s wait. r1 + r2]! tfib3 | t | ^self < 2 ifTrue: [1] ifFalse: [t := [(self - 2) tfib3] forkForJoin. (self - 1) tfib3 + t join]! ! !JoinableProcess class methodsFor: 'instance creation'! forBlock: aBlock priority: anInteger "Answer an instance of me that has suspended aContext at priority anInteger." | newProcess | newProcess := self new. newProcess suspendedContext: [[newProcess result: aBlock value] on: Process terminateSignal do: [:ex | ex return]. Processor activeProcess primTerminate] newContext. newProcess priority: anInteger. ^newProcess! ! !JoinableProcess methodsFor: 'initialization'! initialize super initialize. sync := Semaphore new! ! !JoinableProcess methodsFor: 'synchronization'! join sync wait. ^result! ! !JoinableProcess methodsFor: 'private'! result: anObject result := anObject. sync signal! ! (ChangeSet current respondsTo: #comment:) ifTrue: [ChangeSet current comment: '"| s n | s := String new writeStream. s cr. n := 14. #(tfib1 tfib2 tfib3) do: [:functionName| | milliseconds result | milliseconds := Time millisecondsToRun: [result := n perform: functionName]. s cr; nextPutAll: functionName; nextPutAll: '' = ''; print: result; nextPutAll: '' in ''; print: milliseconds / 1000.0; cr]. s contents '' tfib1 = 610 in 0.066 tfib2 = 610 in 0.037 tfib3 = 610 in 0.045 ''"']!