PerlGameDev / SDL

Rehashing the old perl SDL binding on cpan.org
http://search.cpan.org/dist/SDL
GNU General Public License v2.0
80 stars 28 forks source link

Integrate with Coro::State or similar in callbacks #87

Closed kthakore closed 13 years ago

kthakore commented 13 years ago

SDL makes heavy use of callbacks, so it is important to make it work as coroutines, so that the code interrupted by a callback is reified later.

This also potentially solves the issue with threads and timer, since the timer thread could simply signalize the main thread to switch to a different coroutine, instead of trying to execute the code in the foreign thread...

Usually, for every callback in SDL there's always a pointer for "user defined data", this can be used to store the closure to be called, then the current interpreter state could be sent as a parameter to be reified at the end of the callback in a Continuation Passing Style.

kthakore commented 13 years ago

Author: ruoso Time: 1262649114 Field: status Value: closed

kthakore commented 13 years ago

Author: ruoso Time: 1262649114 Field: resolution Value: fixed

kthakore commented 13 years ago

Author: ruoso Time: 1262649114 Field: comment Value: In the end, the solution was to implement it using threads instead of coro::state, but it does work just fine.