MCPcopy Create free account
hub / github.com/BlueMatthew/WechatExporter / addTask

Method addTask

WechatExporter/core/DownloadPool.cpp:74–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74void DownloadPool::addTask(const std::string &url, const std::string& output)
75{
76 std::string formatedPath = output;
77 std::replace(formatedPath.begin(), formatedPath.end(), DIR_SEP_R, DIR_SEP);
78#ifndef NDEBUG
79 struct stat buffer;
80 if (stat (formatedPath.c_str(), &buffer) == 0)
81 {
82 return;
83 }
84#endif
85
86 std::string uid = url + output;
87 bool existed = false;
88 Task task(url, formatedPath);
89 m_mtx.lock();
90 if (!(existed = (m_urls.find(uid) != m_urls.cend())))
91 {
92 m_urls.insert(uid);
93 m_queue.push(task);
94 }
95 m_mtx.unlock();
96
97 if (existed)
98 {
99#ifndef NDEBUG
100 printf("URL Existed: %s", url.c_str());
101#endif
102 }
103}
104
105void DownloadPool::setNoMoreTask()
106{

Callers

nothing calls this directly

Calls 2

cendMethod · 0.80
statClass · 0.70

Tested by

no test coverage detected