[plt-scheme] Multi-Threaded GUI w/ Text Editor Output

From: Christopher Bowron (cwbowron at gmail.com)
Date: Tue Jun 30 08:40:04 EDT 2009

I have a multithreaded GUI app that uses a text editor for its output port.
Every once in a while, I get an error I believe is related to multiple
threads accessing the text editor output port.

I don't seem to get the error if I leave the outport port alone and use the
default output port from DrScheme.  The error is:

    sequence-contract-violation: negative: method insert cannot be called,
except in states (unlocked), args ...

I install a custom output port using something along the lines of [slightly
condensed from real version]:

(define console%
  (class frame%
    (super-new
     (parent #f)
     (width 720)
     (height 300)
     (label "Console"))
    (define _text-editor (new text%))
    (define _canvas
      (new editor-canvas%
           (parent this)
           (editor _text-editor)))
   (current-output-port (open-output-text-editor _text-editor))))

(define console [new console%])

Is it possible to safely due what I am trying to do?  I just want to create
a frame that has the output to the current-output-port, so that individual
pieces can just write to current-output-port as usual and not have to know
its being redirected to a GUI frame.

I'm using using 4.2 on Windows XP if it matters.

-- 
Christopher W. Bowron <chris at bowron.us>
[ Nothing is exciting if you know what the outcome will be ]
   - Joseph Campbell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090630/f8afb65c/attachment.html>

Posted on the users mailing list.