[clutter-texture] Use a GThreadPool for loading async textures
authorNeil Roberts <neil@linux.intel.com>
Wed, 25 Feb 2009 17:10:54 +0000 (17:10 +0000)
committerNeil Roberts <neil@linux.intel.com>
Wed, 25 Feb 2009 17:52:14 +0000 (17:52 +0000)
commit1626d6132e9bab267463b5f532567e22006771db
tree9b2219647d668b7e28a91f8d3f4112c902256c2c
parent3425331cc167f029bc4b86a66d95d3e498f52514
[clutter-texture] Use a GThreadPool for loading async textures

Instead of creating a separate thread for each texture load, the loads
are now queued in a thread pool which will use at most 3 textures at a
time. This avoids the potentially large overhead of creating and
destroying a thread for every image while still avoiding throttling
the CPU if a large number of textures are loaded at the same time.

If the load is cancelled the old code needed to join the thread which
effectively meant it had to wait for the load to finish. With this
model the threads are owned by the thread pool so there is no need to
wait for them to finish. Instead, each thread is given its own thread
data which we can use to mark the thread as aborted. Once the load is
finished the thread will check whether it is aborted before setting
the texture data. That way the ClutterTexture can just disown threads
that it needs to cancel.
clutter/clutter-texture.c