pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <i id='Yahfz'><tr id='Yahfz'><dt id='Yahfz'><q id='Yahfz'><span id='Yahfz'><b id='Yahfz'><form id='Yahfz'><ins id='Yahfz'></ins><ul id='Yahfz'></ul><sub id='Yahfz'></sub></form><legend id='Yahfz'></legend><bdo id='Yahfz'><pre id='Yahfz'><center id='Yahfz'></center></pre></bdo></b><th id='Yahfz'></th></span></q></dt></tr></i><div class="lpsvuao" id='Yahfz'><tfoot id='Yahfz'></tfoot><dl id='Yahfz'><fieldset id='Yahfz'></fieldset></dl></div>

    <small id='Yahfz'></small><noframes id='Yahfz'>

    • <bdo id='Yahfz'></bdo><ul id='Yahfz'></ul>
  • <legend id='Yahfz'><style id='Yahfz'><dir id='Yahfz'><q id='Yahfz'></q></dir></style></legend>

      <tfoot id='Yahfz'></tfoot>

      1. 關于 Web Worker 中的同步請求的意見

        Opinion about synchronous requests in web workers(關于 Web Worker 中的同步請求的意見)
        <legend id='mwwAH'><style id='mwwAH'><dir id='mwwAH'><q id='mwwAH'></q></dir></style></legend>
          <bdo id='mwwAH'></bdo><ul id='mwwAH'></ul>
              <tbody id='mwwAH'></tbody>
            <i id='mwwAH'><tr id='mwwAH'><dt id='mwwAH'><q id='mwwAH'><span id='mwwAH'><b id='mwwAH'><form id='mwwAH'><ins id='mwwAH'></ins><ul id='mwwAH'></ul><sub id='mwwAH'></sub></form><legend id='mwwAH'></legend><bdo id='mwwAH'><pre id='mwwAH'><center id='mwwAH'></center></pre></bdo></b><th id='mwwAH'></th></span></q></dt></tr></i><div class="rgkn0nm" id='mwwAH'><tfoot id='mwwAH'></tfoot><dl id='mwwAH'><fieldset id='mwwAH'></fieldset></dl></div>

              <tfoot id='mwwAH'></tfoot>

              • <small id='mwwAH'></small><noframes id='mwwAH'>

                  本文介紹了關于 Web Worker 中的同步請求的意見的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想知道您對此有何看法.是否建議在 web worker 中使用同步請求(XMLHttpRequest)?我能找到什么問題?

                  I want to know what do you think about this. Is recommended to use synchronous requests (XMLHttpRequest) in a web worker? What problems can I find?

                  我一直在我的應用程序中對此進行測試,但沒有發現任何問題.但由于 jQuery 和 AJAX 的舊經驗,我害怕這種同步行為.我的應用程序從數據庫中的多個表中獲取大量數據,這需要時間.對于從表中檢索到的每一束數據,我需要立即處理它,以免過多地延遲整個事情.同時,用戶正在與瀏覽器交互,所以它可以被阻止,我認為網絡工作者可以正常工作.你認為這是一個好的解決方案嗎?還是我應該嘗試異步請求?

                  I have been testing this in my app and I haven't find any trouble. But I'm afraid of this synchronus behaviour because of old experiences with jQuery and AJAX. My app gets a big amount of data from several tables in a database, and this requires a time. For each bunch of data retrieved from a table, I need to instantly process it to not delay the whole thing too much. Meanwhile, the user is interacting with the browser, so it can be blocked, and I thought that web workers would work fine. Do you thing that this is a good solution? Or should I try with asynchronus requests?

                  謝謝.

                  推薦答案

                  我沒有確鑿的事實,但既然你征求意見... :)

                  I don't have hard facts, but since you asked for opinions... :)

                  Chrome 中有一個明顯的問題:Web Worker 過多會導致無聲崩潰(根據 這個錯誤報告).一般的問題是 Web Workers 是資源密集型的,至少在 v8 中是這樣.

                  There is a telling issue in Chrome: Too many Web Workers can cause a silent crash (caps ~60-100, according to this bug report). The general problem is Web Workers are resource intensive, at least with v8.

                  假設您最終要進行多個 HTTP 調用,如果您在 Web Worker 中進行同步 HTTP 調用:

                  Assuming you're going to end up making multiple HTTP calls, if you're doing synchronous HTTP calls in a Web Worker:

                  • 從某種意義上說,您正在為異步 Web Worker 交易異步 HTTP 調用,這只會在混合中添加另一個中介,您仍然需要異步管理事物.
                  • 如果您采用更簡單、資源效率更高的路線并且只使用一個 Web Worker,您將花費大量時間等待它給您響應.
                  • 另一方面,如果您使用多個 Web Worker,您可能需要跟蹤哪個是空閑的,哪個是忙碌的,等等,在這種情況下,您將創建一個自制的調度程序而不是使用瀏覽器內置的內容.
                  • 最后,Web Worker 很昂貴(顯然),您最終可能會創建多個 Web Worker,這樣他們就可以坐下來等待 HTTP 調用完成.

                  我不認為自己是這方面的專家,所以請接受它的價值.

                  I do not consider myself an expert on the matter, so please take this for what it's worth.

                  更新:為各種場景添加一些優點/缺點.

                  Update: Adding some pros / cons for various scenarios.

                  在使用 Web Worker 進行同步和異步 HTTP 調用之間進行選擇時想到的一些優點/缺點:

                  Some pros / cons that come to mind when choosing between making synchronous and asynchronous HTTP calls when using a Web Worker:

                  • 通常,同步請求會更容易編寫,并且會生成易于遵循的代碼.同步請求的一個缺點是它們可能會鼓勵編寫長函數,這些函數應該被分割成單獨的更小的函數.
                  • 如果您只進行一次調用,則兩種方法完成所需的時間沒有區別,同步更好,因為它更簡單一些.我說它只是簡單一點,因為帶有一個回調偵聽器的單個異步調用確實相當簡單.
                  • 如果您要以特定順序進行多次調用,例如加載用戶的個人資料數據,然后根據他們的地址獲取當地天氣,那么同步調用會更好,因為它更容易編寫并且更容易閱讀.閱讀它的主要內容是調用中的順序依賴關系將通過選擇同步進行調用及其在函數中的順序來清楚地概述.呼叫越多,這就越重要.如果調用很多,復雜度上的差異可能會很大.
                  • 如果您必須進行不需要以任何特定順序發生的多次調用,那么異步請求會更好,因為整個過程可能比同步請求快幾個數量級.您撥打的電話越多或連接速度越慢,總經過時間的差異就越大;這種差異會迅速增長(呈指數增長?).從閱讀代碼的人的角度來看,我認為在這種情況下使用同步請求會有點誤導,因為它表明調用具有順序性,即使沒有.從編寫一系列不依賴于彼此的異步請求的角度來看,這應該不會太糟糕,因為您只需設置一個計數器,進行所有調用,在每個回調中遞增計數器,您就完成了當計數器等于您撥打的電話次數時.
                  • Generally, synchronous requests will be easier to write and will result in code that is easy to follow. A downside of synchronous requests is they might encourage writing long functions that should be carved out into separate, smaller functions.
                  • If you're making a single call, there is no difference in the time it takes to finish between the two methods and synchronous is better because it's a bit simpler. I say it's only a bit simpler because a single asynch call with one callback listener is really rather simple.
                  • If you're making multiple calls that have to happen in a specific sequence, like loading a user's profile data and then getting the local weather based on their address, synchronous calls will be better because it will be easier to write and a lot easier to read. The main thing about reading it is the sequential dependencies in the calls will be clearly outlined by the choice of making the calls synchronously and their order in the function. The more calls there are, the more this will matter. If there are many calls, the difference in complexity is likely to be drastic.
                  • If you have to make multiple calls that do not need to happen in any specific order, then asynchronous requests are better because the overall process is likely to be orders of magnitude faster than with synchronous requests. The more calls you're making or the slower the connection, the more significant the difference in total elapsed time will be; this difference will grow very quickly (exponentially?). From the perspective of someone reading the code, I think using synchronous requests, in this situation, would be somewhat misleading as it would suggest there is a sequential nature to the calls even though there is not. From the perspective of writing a series of asynch requests that are not dependent on each other, it shouldn't be too bad because you just setup a counter, make all the calls, increment the counter in each of the callbacks and you're finished when the counter equals the number of calls you made.

                  更新:@rbrundritt 制作了一個非常有趣且相關的 對此答案的評論中的觀察:

                  Update: @rbrundritt makes a very interesting and relevant observation in a comment on this answer:

                  我發現與網絡工作者一起工作的一件事是,他們似乎每個人都獲得了自己的 http 限制.瀏覽器將并發 http 請求的數量限制在 8 或 12 左右,具體取決于限制之前的瀏覽器,如果您有大量請求要處理,這可能是一個瓶頸.我發現如果我通過我的請求網絡工作者,每個人可以在開始節流之前執行 8 到 12 個并發請求.這對某些應用來說可能是一個巨大的好處.

                  One thing I found working with web workers is that they appear to each gain their own http limit. Browsers limit the number of concurrent http requests to around 8 or 12 depending on the browser before throttling, which can be a bottle neck if you have a lot of requests to process. I've found that if I pass my requests web workers, each can do 8 to 12 concurrent requests before they start throttling. This can be a huge benefit for some apps.

                  @rbrundritt

                  這篇關于關于 Web Worker 中的同步請求的意見的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                    <tbody id='FgYsr'></tbody>
                  <i id='FgYsr'><tr id='FgYsr'><dt id='FgYsr'><q id='FgYsr'><span id='FgYsr'><b id='FgYsr'><form id='FgYsr'><ins id='FgYsr'></ins><ul id='FgYsr'></ul><sub id='FgYsr'></sub></form><legend id='FgYsr'></legend><bdo id='FgYsr'><pre id='FgYsr'><center id='FgYsr'></center></pre></bdo></b><th id='FgYsr'></th></span></q></dt></tr></i><div class="xmbpwcx" id='FgYsr'><tfoot id='FgYsr'></tfoot><dl id='FgYsr'><fieldset id='FgYsr'></fieldset></dl></div>
                        <bdo id='FgYsr'></bdo><ul id='FgYsr'></ul>

                        <small id='FgYsr'></small><noframes id='FgYsr'>

                        <tfoot id='FgYsr'></tfoot>

                        1. <legend id='FgYsr'><style id='FgYsr'><dir id='FgYsr'><q id='FgYsr'></q></dir></style></legend>

                            主站蜘蛛池模板: 钢格板|镀锌钢格板|热镀锌钢格板|格栅板|钢格板|钢格栅板|热浸锌钢格板|平台钢格板|镀锌钢格栅板|热镀锌钢格栅板|平台钢格栅板|不锈钢钢格栅板 - 专业钢格板厂家 | 内六角扳手「厂家」-温州市威豪五金工具有限公司 | 半容积式换热器_北京浮动盘管换热器厂家|北京亿丰上达 | 天一线缆邯郸有限公司_煤矿用电缆厂家_矿用光缆厂家_矿用控制电缆_矿用通信电缆-天一线缆邯郸有限公司 | 首页|成都尚玖保洁_家政保洁_开荒保洁_成都保洁 | 保定市泰宏机械制造厂-河北铸件厂-铸造厂-铸件加工-河北大件加工 | 电缆接头_防水接头_电缆防水接头_防水电缆接头_上海闵彬 | 刚性-柔性防水套管-橡胶伸缩接头-波纹管补偿器-启腾供水材料有限公司 | 缝纫客| 诺冠气动元件,诺冠电磁阀,海隆防爆阀,norgren气缸-山东锦隆自动化科技有限公司 | 井式炉-台车式回火炉-丹阳市电炉厂有限公司 | 上海噪音治理公司-专业隔音降噪公司-中广通环保 | 湖南印刷厂|长沙印刷公司|画册印刷|挂历印刷|台历印刷|杂志印刷-乐成印刷 | 机械加工_绞车配件_立式离心机_减速机-洛阳三永机械厂 | 超细|超微气流粉碎机|气流磨|气流分级机|粉体改性机|磨粉机|粉碎设备-山东埃尔派粉体科技 | 隐形纱窗|防护纱窗|金刚网防盗纱窗|韦柏纱窗|上海青木装潢制品有限公司|纱窗国标起草单位 | 温州富欧金属封头-不锈钢封头厂家| 球磨机,节能球磨机价格,水泥球磨机厂家,粉煤灰球磨机-吉宏机械制造有限公司 | 皮带式输送机械|链板式输送机|不锈钢输送机|网带输送机械设备——青岛鸿儒机械有限公司 | 阀门智能定位器_电液动执行器_气动执行机构-赫尔法流体技术(北京)有限公司 | 智慧农业|农业物联网|现代农业物联网-托普云农物联网官方网站 | 招商帮-一站式网络营销服务|搜索营销推广|信息流推广|短视视频营销推广|互联网整合营销|网络推广代运营|招商帮企业招商好帮手 | 分光色差仪,测色仪,反透射灯箱,爱色丽分光光度仪,美能达色差仪维修_苏州欣美和仪器有限公司 | 济南侦探调查-济南调查取证-山东私家侦探-山东白豹调查咨询公司 密集架|电动密集架|移动密集架|黑龙江档案密集架-大量现货厂家销售 | 神马影院-实时更新秒播 | 太原装修公司_山西整装家装设计_太原室内装潢软装_肖邦家居 | 首页-恒温恒湿试验箱_恒温恒湿箱_高低温试验箱_高低温交变湿热试验箱_苏州正合 | 阿尔法-MDR2000无转子硫化仪-STM566 SATRA拉力试验机-青岛阿尔法仪器有限公司 | LZ-373测厚仪-华瑞VOC气体检测仪-个人有毒气体检测仪-厂家-深圳市深博瑞仪器仪表有限公司 | 全自动包衣机-无菌分装隔离器-浙江迦南科技股份有限公司 | 气弹簧定制-气动杆-可控气弹簧-不锈钢阻尼器-工业气弹簧-可调节气弹簧厂家-常州巨腾气弹簧供应商 | 浙江华锤电器有限公司_地磅称重设备_防作弊地磅_浙江地磅售后维修_无人值守扫码过磅系统_浙江源头地磅厂家_浙江工厂直营地磅 | 油罐车_加油机_加油卷盘_加油机卷盘_罐车人孔盖_各类球阀_海底阀等车用配件厂家-湖北华特专用设备有限公司 | 工业淬火油烟净化器,北京油烟净化器厂家,热处理油烟净化器-北京众鑫百科 | LED显示屏_LED屏方案设计精准报价专业安装丨四川诺显科技 | 拉力机-万能试验机-材料拉伸试验机-电子拉力机-拉力试验机厂家-冲击试验机-苏州皖仪实验仪器有限公司 | 3d打印服务,3d打印汽车,三维扫描,硅胶复模,手板,快速模具,深圳市精速三维打印科技有限公司 | 膏剂灌装旋盖机-眼药水灌装生产线-西林瓶粉剂分装机-南通博琅机械科技 | 成都离婚律师|成都结婚律师|成都离婚财产分割律师|成都律师-成都离婚律师网 | 板框压滤机-隔膜压滤机配件生产厂家-陕西华星佳洋装备制造有限公司 | 广东高华家具-公寓床|学生宿舍双层铁床厂家【质保十年】 |