How to limit the amount of concurrent async I/O operations?

前端 未结 14 2470
遇见更好的自我
遇见更好的自我 2020-11-22 01:27
// let\'s say there is a list of 1000+ URLs
string[] urls = { \"http://google.com\", \"http://yahoo.com\", ... };

// now let\'s send HTTP requests to each of these          


        
14条回答
  •  甜味超标
    2020-11-22 02:12

    Parallel computations should be used for speeding up CPU-bound operations. Here we are talking about I/O bound operations. Your implementation should be purely async, unless you're overwhelming the busy single core on your multi-core CPU.

    EDIT I like the suggestion made by usr to use an "async semaphore" here.

提交回复
热议问题