Commit Graph

5 Commits

Author SHA1 Message Date
rdb 5f0f005723 tests: add various tests for PythonTask.__dict__ access 2019-03-04 22:59:17 +01:00
rdb 4bc0a1ef5e tests: fix futures test when building without true threading 2018-10-17 17:28:25 +02:00
rdb ec06d3f4f8 tests: fix occasional timing issue in future test 2018-07-05 12:59:02 +02:00
rdb ed5e5386b9 AsyncFuture improvements, incl. support for gathering futures 2017-12-21 14:07:01 +01:00
rdb 2e20a0f16e Implement awaitable thread-safe future for async operations
This introduces AsyncFuture as a new base class of AsyncTask.  It's modelled after asyncio's Future class, except that it is thread-safe and you can use result() to block the current thread waiting for the future to finish (of course this is not necessary for use with coroutines).

AsyncFuture should be used for any operation that finishes in the future, to get the benefit of awaitability within coroutines as well as a standard interface for querying status and results of the operation as well as cancelling it.  As such, it's been implemented in various places, including texture.prepare() and win.trigger_copy().

Note that AsyncFuture is intended to be used *once*; it cannot be used more than once.  As an example of how this works, tex.prepare() will return the same future as long as the prepare isn't complete, but when it is done, subsequent calls to tex.prepare() will return a new future.
2017-12-04 22:25:28 +01:00