On Wed, May 13, 2015 at 6:32 AM, Alain Rastoul <[email protected]> wrote:
> Le 12/05/2015 19:02, Alain Rastoul a écrit : > >> Le 08/05/2015 11:34, stepharo a écrit : >> >>> Hi guys >>> >>> the Transcript in Pharo is that it's not asynchronous so I can't use it >>> in VM development to show the current progress of the simulation. For >>> example: >>> 1 to: 100 do: [ :i | >>> 0.1 seconds asDelay wait. >>> Transcript show: 'x'. ] >>> => on Squeak, this shows a x every 0.1 second in the Transcript >>> => on Pharo, nothing happens during 10 seconds then all the x are shown. >>> >>> https://pharo.fogbugz.com/default.asp?15515 >>> >>> >>> Hi, >> I updated the fogbugz entry with a changeset containing the sources Stef >> already put here, so that it should be easy for anybody to load >> CuisTranscript into a Pharo image and have a look. >> >> IMHO another solution has to be found, or a big review of this has to be >> done. >> see details in fogbugz entry. >> >> > A very ugly but simple workaround could be > > ThreadSafeTranscript>>endEntry: > accessSemaphore critical: [ > deferredEndEntry := true . > " is Synchronous coudl be a setting" > self isSynchronous > ifTrue: [ > self stepGlobal . "handles appendEntry" > World displayWorldSafely "redraw now" ] ]. > > with a setings for isSynchronous > ugly but works, > > The problem with this is that non-UI threads call #endEntry: which bypasses the intent of #stepGlobal only being called from the UI thread. (btw I should update its comment to reflect this.) So the minimal effective change would be... ThreadSafeTranscript>>endEntry: accessSemaphore critical: [ deferredEndEntry := true ]. (UIManager default uiProcess = Processor activeProcess) ifTrue: [ self stepGlobal. World displayWorldSafely. ]. However this would need to massaged to remove the referenced global classes (UIManager and World) to avoid introducing dependencies breaking the Image shrink work. Maybe these can be passed into the Transcript object where #stepGlobal is currently called from. Note that #stepGlobal already uses accessSemaphore, so doesn't need to be protected here. cheers -ben
