更新目录结构
This commit is contained in:
103
Components/MultiplethreadDownload/REAMDE.md
Normal file
103
Components/MultiplethreadDownload/REAMDE.md
Normal file
@@ -0,0 +1,103 @@
|
||||
文件大小为: 2521709
|
||||
开始下载文件
|
||||
开始下载数据: 1891281~2521709 -> writePos Start 1891281
|
||||
开始下载数据: 0~630426 -> writePos Start 0
|
||||
开始下载数据: 630427~1260853 -> writePos Start 630427
|
||||
开始下载数据: 1260854~1891280 -> writePos Start 1260854
|
||||
|
||||
|
||||
文件大小为: 89937570
|
||||
开始下载文件
|
||||
开始下载数据: " 0~22484391 -> writePos Start 0"
|
||||
开始下载数据: " 22484392~44968783 -> writePos Start 22484392"
|
||||
开始下载数据: " 44968784~67453175 -> writePos Start 44968784"
|
||||
开始下载数据: " 67453176~89937570 -> writePos Start 67453176
|
||||
|
||||
|
||||
# 星火商店多线程下载说明
|
||||
现在的这个多线程下载已经可以了,但是暂停恢复不太好控制,所以还是用 QThread 来做暂停控制,即使线程数超过CPU
|
||||
核数问题也不大,因为下载并不是CPU密集操作,完全没问题的。总体的精细的线程池控制后续技术强大了再来封装好了。
|
||||
|
||||
先做好这个功能,后续再来研究DTK库,各个组件的使用,已经如何自己封装漂亮的控件,摆脱DTK的依赖。
|
||||
再后面,写一个Qt开发Linux应用的教程,先建立起星火商店单独的开发者博客,专门用来发技术文章。
|
||||
|
||||
星火商店的几个源服务器,源列表写在
|
||||
```sh
|
||||
$ cat /etc/apt/sources.list.d/sparkstore.list
|
||||
deb [by-hash=force] https://sucdn.jerrywang.top /
|
||||
```
|
||||
|
||||
服务器源列表 http://dcstore.shenmo.tech/store/server.list
|
||||
```js
|
||||
https://sucdn.jerrywang.top/
|
||||
国内推荐 China Lines
|
||||
https://sucdn.jerrywang.top/
|
||||
https://store.deepinos.org.cn/
|
||||
国外推荐 Global Lines
|
||||
开发者模式 Dev only
|
||||
http://localhost:8080/
|
||||
用户贡献 Community lines
|
||||
```
|
||||
|
||||
也就是目前的就两个服务器了
|
||||
* https://sucdn.jerrywang.top/
|
||||
* https://store.deepinos.org.cn/
|
||||
|
||||
|
||||
原来的单线程相关代码
|
||||
```cpp
|
||||
// 在处理下载进度的代码中,会一直检测下载是否取消
|
||||
void Widget::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
|
||||
{
|
||||
if(totalBytes <= 0) return;
|
||||
download_list[nowDownload-1].setMax(10000); // 最大值
|
||||
download_list[nowDownload-1].setValue((bytesRead*10000)/totalBytes); // 当前值
|
||||
download_size=bytesRead;
|
||||
if(download_list[nowDownload-1].close){ // 随时检测下载是否被取消
|
||||
download_list[nowDownload-1].closeDownload();
|
||||
httpFinished();
|
||||
}
|
||||
}
|
||||
// 但是这里的 download_list[nowDownload-1].close 是在哪里修改的呢?
|
||||
downloadlist download_list[LIST_MAX];
|
||||
download_list 是一个下载进度组件,维持动画的,还不错。
|
||||
|
||||
// 星火商店记录下载进度的代码
|
||||
void Widget::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
|
||||
{
|
||||
if(totalBytes <= 0) return;
|
||||
download_list[nowDownload-1].setMax(10000); // 最大值
|
||||
download_list[nowDownload-1].setValue((bytesRead*10000)/totalBytes); // 当前值
|
||||
download_size=bytesRead;
|
||||
if(download_list[nowDownload-1].close){ // 随时检测下载是否被取消
|
||||
download_list[nowDownload-1].closeDownload();
|
||||
httpFinished();
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::httpFinished() // 完成下载
|
||||
{
|
||||
file->flush();
|
||||
file->close();
|
||||
reply->deleteLater();
|
||||
reply = nullptr;
|
||||
delete file;
|
||||
file = nullptr;
|
||||
isdownload=false;
|
||||
isBusy=false;
|
||||
}
|
||||
```
|
||||
|
||||
然后那个多线程下载组件需要的几个功能点:
|
||||
* 下载进度,以及下载速度记录
|
||||
* 下载取消功能
|
||||
* 读取设置,允许设置单线程下载 这个可以放到后面做,优先实现上面两个
|
||||
|
||||
多域名测试下载,现在单个域名至多5M,DNS解析均衡有延迟,因为DNS会有缓存。
|
||||
```url
|
||||
sucdn1.jerrywang.top
|
||||
sucdn2.jerrywang.top
|
||||
sucdn3.jerrywang.top
|
||||
sucdn4.jerrywang.top
|
||||
sucdn5.jerrywang.top
|
||||
```
|
||||
Reference in New Issue
Block a user