加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

RSL(包括ResourceModule)是并发被加载的还是顺序被加载的? --

发布时间:2020-12-15 05:11:36 所属栏目:百科 来源:网络整理
导读:RSL不只一个,这些RSL被Flex框架串行加载,即加载完一个后再加载下一个。 ? 源代码片断佐证: mx.core.RSLListLoader.as package mx.core { ?//构造函数,调用函数loadNext()加载第一个RSL ??public function load(progressHandler:Function, ??????????????

RSL不只一个,这些RSL被Flex框架串行加载,即加载完一个后再加载下一个。

?

>>源代码片断佐证: mx.core.RSLListLoader.as

package mx.core
{

?//构造函数,调用函数loadNext()加载第一个RSL
??public function load(progressHandler:Function,
????????????????????? completeHandler:Function,
????????????????????? ioErrorHandler:Function,
????????????????????? securityErrorHandler:Function,
????????????????????? rslErrorHandler:Function):void
??? {
??? ?chainedProgressHandler = progressHandler;
???? chainedCompleteHandler = completeHandler;
???? chainedIOErrorHandler = ioErrorHandler;
???? chainedSecurityErrorHandler = securityErrorHandler;
???? chainedRSLErrorHandler = rslErrorHandler;
????
???? currentIndex = -1; // so first loaded item will be index 0
???? loadNext();
????????
??? }
????

??? //加载RSL
??? private function loadNext():void
??? {
??????? if (!isDone())
??????? {
??????????? currentIndex++;

???????? // Load the current RSL.
???????? if (currentIndex < rslList.length)
???????? {
???????????? // Load rsl and have the RSL loader chain the
???????????? // events our internal events handler or the chained
???????????? // events handler if we don't care about them.
???????????? rslList[currentIndex].load(chainedProgressHandler,
??????????????????????????????????????? listCompleteHandler,
??????????????????????????????????????? listIOErrorHandler,
??????????????????????????????????????? listSecurityErrorHandler,
??????????????????????????????????????? chainedRSLErrorHandler);
???????? }
??????? }
??? }

?

? //一个RSL加载完毕后,再加载下一个????
?private function listCompleteHandler(event:Event):void
??? {
??????? // Pass event to external listener.
??????? if (chainedCompleteHandler != null)
??????????? chainedCompleteHandler(event);

??????? // Load the next RSL.
???????
loadNext();
??? }

}

?

========================================================================

>>猜测:为什么不采用并发下载?

(1)。FlashPlayer的并发下载功能有缺陷,造成并发下载的时候会莫名出现问题。

???????? 参考: 《同时new了多个URLLoader 加载文件时所遇到的问题》

??????????????????? http://bbs.9ria.com/thread-88518-1-1.html

(2)。http协议中对客户端请求连接数的限制

???????? 参考: 《IE并发连接限制(as)AS队列加载类(as3和as2)》

??????????????????? http://kb.cnblogs.com/a/1583038/??

???????? 参考: 《“HTTP协议对客户端并发连接数目的限制” vs “Flex并行上传或下载” 》

??????????????????? http://www.voidcn.com/article/p-wzvobwfl-bdn.html

(3)。基于(2),代码形式上并行了,但其本质不过是有限数量的并发连接,剩下的连接处于等待状态而已。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读