Skip to content

Commit

Permalink
Merge pull request #80 from hookborealis/master
Browse files Browse the repository at this point in the history
Added slot for chunk hash completion
  • Loading branch information
rakshasa committed Aug 3, 2016
2 parents 0042d93 + 1a979bc commit 4075a3b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/download/download_wrapper.cc
Expand Up @@ -241,6 +241,7 @@ DownloadWrapper::receive_hash_done(ChunkHandle handle, const char* hash) {
}
}

data()->call_chunk_done(handle.object());
m_main->chunk_list()->release(&handle);
}

Expand Down
8 changes: 6 additions & 2 deletions src/torrent/data/download_data.h
Expand Up @@ -45,7 +45,7 @@
#include <torrent/utils/ranges.h>

namespace torrent {

class ChunkListNode;
class ChunkSelector;
class Download;
class DownloadWrapper;
Expand All @@ -59,6 +59,8 @@ class download_data {

typedef std::function<function_void> slot_void;

typedef void (function_chunk_list_node_p)(ChunkListNode *);
typedef std::function<function_chunk_list_node_p> slot_chunk_list_node_p;
download_data() : m_wanted_chunks(0) {}

const HashString& hash() const { return m_hash; }
Expand All @@ -81,6 +83,7 @@ class download_data {
slot_void& slot_download_done() const { return m_slot_download_done; }
slot_void& slot_partially_done() const { return m_slot_partially_done; }
slot_void& slot_partially_restarted() const { return m_slot_partially_restarted; }
slot_chunk_list_node_p& slot_chunk_done() const {return m_slot_chunk_done;}

protected:
friend class ChunkList;
Expand All @@ -103,7 +106,7 @@ class download_data {
void call_download_done() { if (m_slot_download_done) m_slot_download_done(); }
void call_partially_done() { if (m_slot_partially_done) m_slot_partially_done(); }
void call_partially_restarted() { if (m_slot_partially_restarted) m_slot_partially_restarted(); }

void call_chunk_done(ChunkListNode* chunk_ptr) {if(m_slot_chunk_done) m_slot_chunk_done(chunk_ptr);}
private:
HashString m_hash;

Expand All @@ -119,6 +122,7 @@ class download_data {
mutable slot_void m_slot_download_done;
mutable slot_void m_slot_partially_done;
mutable slot_void m_slot_partially_restarted;
mutable slot_chunk_list_node_p m_slot_chunk_done;
};

}
Expand Down

0 comments on commit 4075a3b

Please sign in to comment.