[Vm-dev] Win32 Event VM prototype
Andreas Raab
andreas.raab at gmx.de
Sat Nov 14 06:02:18 UTC 2009
Folks -
I just finished a prototype of the Win32 event VM to illustrate some of
the practical impact. It makes a really nice demo:
1) Download the VM from
http://squeakvm.org/win32/experimental/Squeak-3.11-EventVM.zip
2) Fire up an image with this VM (I used a trunk image) and execute
AbstractSound stereoBachFugue play.
3) Observe the sound behavior you get when you:
* drag the window around
* go to the system menu
* click the window close button
In all of the above situations the sound play will be interrupted,
replaying the current buffer over and over.
4) Execute the following:
(ProcessorScheduler classPool at: #BackgroundProcess) terminate.
You should see a printf that tells you "entering windows main loop"
which indicates that you're now running under the new regime.
5) Observe the sound behavior you get when you:
* drag the window around
* go to the system menu
* click the window close button
In all of these situations the sound will now keep playing. There can be
a temporary hickup due to lack of buffering but other than that
everything continues smoothly.
For those interested I'm attaching the relevant changes (only for
playing around; these changes are NOT ready to be integrated). The
Windows main loop has been changed to read like here:
/* prepare active process and do first time interpret() for old images */
prepareActiveProcess();
/* do not allow recursive interpret() */
allowInterpret = 0;
/* interpret() will be left after nuking background process */
interpret();
/* now do a classic Windows main loop */
printf("Entering Windows Main Loop\n");
SetTimer(stWindow, 1, 50, NULL); /* make sure we interpret() every
50ms */
allowInterpret = 1; /* okay to interpret() now */
while (GetMessage(&msg, NULL, 0, 0) > 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
and then you call interpret() whenever you feel like it. I'm doing that
from MainWndProc in response to Windows messages:
/* A bit of extra paranoia: I'm not sure if calling interpret()
through checkForInterrupt() recursion into ioProcessEvents()
is safe (probably not). */
if(!inProcessEvents && allowInterpret) interpret();
Of course, this isn't finished yet by any means. There are some odd
effects when a recursion does happen, and somewhere I'm loosing events.
But I think it does illustrate the point that I'm trying to make.
BTW, does anyone know if wxSqueak is still active? I think the behavior
of this VM would be a perfect fit for their needs.
Cheers,
- Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: EventVM.1.cs
Type: text/x-csharp
Size: 10530 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20091113/970e2f4e/EventVM.1.bin
More information about the Vm-dev
mailing list