There's a bit too much code to post here so, I'll post the github links:
From the comments in the PhotoTask
class:
This class manages
PhotoDecodeRunnable
andPhotoDownloadRunnable
objects. It doesn't perform the download or decode; instead, it manages persistent storage for the tasks that do the work. It does this by implementing the interfaces that the download and decode classes define, and then passing itself as an argument to the constructor of a download or decode object. In effect, this allows PhotoTask to start on a Thread, run a download in a delegate object, then run a decode, and then start over again. This class can be pooled and reused as necessary.
The comment regards PhotoTask
as "manages persistent storage for the tasks". Is this the delegate pattern? I'd be appreciative of any knowledge that you have regarding these classes and, the pattern.
The PhotoManager
uses an Object Pool pattern, or more specifically a Thread Pool , as it creates, manages and reuses thread instances in a pool.
Runnable
classes in general use the Command pattern , which is way to imitate delegates without function pointers by encapsulating a method call.
The PhotoTask
uses multiple runnables and implements their interface. It delegates its actions to the runnables, which actually looks like a Facade to me, to hide the complexity and encapsulate a specific task.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.