*
*/
+// INTERNAL INCLUDES
#include "resource-loader.h"
-#include <deque>
-#include <boost/thread.hpp>
-
+#include "resource-loading-client.h"
#include <dali/integration-api/platform-abstraction.h>
#include <dali/integration-api/resource-cache.h>
+// EXTERNAL INCLUDES
+#include <deque>
+#include <boost/thread.hpp>
+
namespace Dali
{
/**
* Resource loader worker thread
*/
-class ResourceThreadBase
+class ResourceThreadBase : public ResourceLoadingClient
{
public:
// typedefs and enums
{
/** Pull a resource out of the platform's file system. */
RequestLoad,
+ /** Pull a resource over http protocol. */
+ RequestDownload,
/** Pull a resource out of a memory buffer. */
RequestDecode,
/** Push a resource's data out to the file system. */
typedef RequestQueue::iterator RequestQueueIter;
public:
- // C'tors and D'tors
+ // Constructor
ResourceThreadBase(ResourceLoader& resourceLoader);
+
+ // Destructor
virtual ~ResourceThreadBase();
protected:
virtual void Load(const Integration::ResourceRequest& request) = 0;
/**
+ * Download a resource
+ * @param[in] request The requested resource/file url and attributes
+ */
+ virtual void Download(const Integration::ResourceRequest& request);
+
+ /**
* Decode a resource exactly as if it were being loaded but source its data
* from a memory buffer attached directly to the request object.
* @param[in] request The requested resource data and attributes
*/
virtual void Save(const Integration::ResourceRequest& request) = 0;
+ /**
+ * @brief Cancels current resource request if it matches the one latched to be cancelled.
+ *
+ * @copydoc ResourceLoadingClient::InterruptionPoint
+ */
+ virtual void InterruptionPoint() const;
+
protected:
ResourceLoader& mResourceLoader;
boost::thread* mThread; ///< thread instance
boost::condition_variable mCondition; ///< condition variable
boost::mutex mMutex; ///< used to protect mQueue
RequestQueue mQueue; ///< Request queue
- bool mPaused; ///< Whether to process work in mQueue
+private:
+ Integration::ResourceId mCurrentRequestId; ///< Current request, set by worker thread
+ volatile Integration::ResourceId mCancelRequestId; ///< Request to be cancelled on thread: written by external thread and read by worker.
+ bool mPaused; ///< Whether to process work in mQueue
#if defined(DEBUG_ENABLED)
public: