本文整理汇总了C++中Downloader::download方法的典型用法代码示例。如果您正苦于以下问题:C++ Downloader::download方法的具体用法?C++ Downloader::download怎么用?C++ Downloader::download使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Downloader
的用法示例。
在下文中一共展示了Downloader::download方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testCriticalChunkSpread
void testCriticalChunkSpread()
{
DummyTorrentCreator creator;
bt::TorrentControl tc;
QVERIFY(creator.createSingleFileTorrent(2*TEST_FILE_SIZE,"test2.avi"));
Out(SYS_GEN|LOG_DEBUG) << "Created " << creator.torrentPath() << endl;
try
{
tc.init(0,creator.torrentPath(),creator.tempPath() + "tor0",creator.tempPath() + "data/");
tc.createFiles();
}
catch (bt::Error & err)
{
Out(SYS_GEN|LOG_DEBUG) << "Failed to load torrent: " << creator.torrentPath() << endl;
QFAIL("Torrent load failure");
}
ExtendedStreamingChunkSelector* csel = new ExtendedStreamingChunkSelector();
tc.setChunkSelector(csel);
QVERIFY(csel != 0);
Downloader* downer = csel->downloader();
QVERIFY(downer != 0);
// Check that critical chunks are spread over multiple peers
csel->setSequentialRange(20,60);
DummyDownloader dd[32];
for (Uint32 i = 0;i < 32;i++)
{
downer->addPieceDownloader(&dd[i]);
}
// Check the spread of the downloaders
downer->update();
for (Uint32 i = 20;i < csel->criticialWindowSize();i++)
{
QVERIFY(downer->downloading(i));
QVERIFY(downer->download(i)->getNumDownloaders() == 32 / csel->criticialWindowSize());
}
for (Uint32 i = 0;i < 32;i++)
{
QVERIFY(dd[i].getNumGrabbed() == 1);
}
for (Uint32 i = 0;i < 32;i++)
{
downer->removePieceDownloader(&dd[i]);
}
// cleanup
tc.setChunkSelector(0);
}
示例2: dsp
void testObj::test<3>(void)
{
// note that there is race condition in next two lines - it may happen that between
// download of blacklisted IPs by strategy and download by donwloader it may change
// thus there is some (small) probablilty that this test will randomly fail.
const Downloader dwnl(1); // just one entry to download
const DShieldParser dsp( dwnl.download() ); // parse it
Strategy s( InstanceName("x"), Strategy::Parameters(1, 10, 0.5) ); // initiliaze strategy to use
ensure("no entries parsed", dsp.begin()!=dsp.end() );
GraphNodePtrNN leaf=makeNewLeaf( (*dsp.begin()).to_string().c_str() ); // make leaf that is blacklisted
// this host should be blacklisted
s.process(leaf, changed_);
ensure_equals("nothing changed", changed_.size(), 1u);
changed_.clear();
// now it should NOT be blacklisted, since it has already changed
s.process(leaf, changed_);
ensure_equals("the same host has been black-listed twice", changed_.size(), 0u);
}