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

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Jun 30 09:06:41 EDT 2009

At Tue, 30 Jun 2009 08:40:04 -0400, Christopher Bowron wrote:
> 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 ...

Yes, that's almost certainly due to using the editor from multiple threads.

> Is it possible to safely due what I am trying to do? 

The usual solution is to use `queue-callback' to insert characters,
instead of inserting directly from the current thread. But
`open-output-text-editor' doesn't give you a way to do that.

Probably `open-output-text-editor' should accept an eventspace to use
for all editor operations, and I'll try making that change soon.

Posted on the users mailing list.