Skip to content

Timeout or break in MessageLoop [RT #15538] #4

@Vivtek

Description

@Vivtek

This is addressed in RT issue [https://rt.cpan.org/Public/Bug/Display.html?id=15538] - essentially, there are times when the automation object can't be trusted to send any more events, and that leaves us stranded in MessageLoop with no way to time out.

A cheap and easy way to implement an optional break-out would simply be to pass a closure in, and call it with call_sv on every trip through the loop. I feel like that would maybe call the closure too often, but I have no feel for how that would be decided or measured. It would, however, be easy. You wouldn't even have to monitor any return - the callback could simply QuitMessageLoop if that's what was appropriate.

I'm going to code this in the next day or two unless somebody tells me it's stupid. I'm pretty sure Windows will regulate how often the message loop gets called, in other words, that tight loop isn't actually using any meaningful system resources except what it costs to run a Perl function in the first place.

The alternative would be to do a SetTimer and trap the WM_TIMER; then, however, QuitMessageLoop would probably need to kill the timer. That feels as though it would be a leak risk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions