当前位置: 首页>>代码示例>>C++>>正文


C++ Downloader::download方法代码示例

本文整理汇总了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);
	}
开发者ID:netrunner-debian-kde-extras,项目名称:libktorrent,代码行数:52,代码来源:streamingchunkselectortest.cpp

示例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);
}
开发者ID:el-bart,项目名称:ACARM-ng,代码行数:18,代码来源:Strategy.t.cpp


注:本文中的Downloader::download方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。