[Python-Dev] pre-PEP: The Safe Buffer Interface

Neil Hodgson nhodgson@bigpond.net.au
Tue, 30 Jul 2002 19:48:44 +1000


Scott Gilbert:

> You've listed three possibilities, but lets narrow it down to the strategy
> that you intend to use in Scintilla (a real use case).  I believe all
three
> strategies lead to something undesirable (be it polling, deadlock, a
> confused user, or ???), but I don't want to exhaustively scrutinize all
> possibilities until we come up with one good example that you intend to
use
> (it would bore you to read them, and me to type them).
>
> So what exactly would you do in Scintilla?  (Or pick another good use case
> if you prefer.)

   I'd prefer to ignore the input. Unfortunately users prefer a higher
degree of friendliness :-(

   Since Scintilla is a component within a user interface, it shares this
responsibility with the container application with the application being the
main determinant. If I was writing a Windows-specific application that used
Scintilla, and I wanted to use Asynchronous I/O then my preferred technique
would be to change the message processing loop to leave the UI input
messages in the queue until the I/O had completed.
   Once the I/O had completed then the message loop would change back to
processing all messages which would allow the banked up input to come
through.
   If I was feeling ambitious I may try to process some UI messages,
possible detecting pressing Escape to abort a file load if it turned out the
read was taking too long.

> A single lock interface can be implemented over an object without any
> locking.  Have the lockable object return simple "fixed buffer objects"
> with a limited lifespan.

   This returns to the possibility of indeterminate lifespan as mentioned
earlier in the thread.

> At which point I wonder what using asynchronous I/O achieved since the
> resize operation had to wait synchronously for the I/O to complete.  This
> also sounds suspiciously like blocking the resize thread, but I won't
argue
> that point.

   There may be other tasks that the application can perform while waiting
for the I/O to complete, such as displaying, styling or line-wrapping
whatever text has already arrived (assuming that there are some facilities
for discovering this) or performing similar tasks for other windows.

   Neil