[Gambas-user] how to make threats

Tobias Boege taboege at ...626...
Wed Nov 13 21:29:28 CET 2013


On Wed, 13 Nov 2013, Sebastian Kulesz wrote:
> I had the same problem, you can look at my solution here [0]. Basically, i
> used a pool of HttpClients with the async property set to True.
> 
> The logic goes like this. I have an index files which tracks around 120
> files stored online. Not going to get into how i update each file without
> downloading the rest, but suppose i want to download all files to build a
> local copy. By default, i create an array of 10 HttpClient instances. With
> DEFAULT_CLIENT_COUNT you can set it to be more.
> I then load each URL into a queue and start a timer which runs every 10 ms.
> In each run, the timer checks for a free HttpClient instance, if there is
> one it loads it with the popped  URL and saves the file into a predefined
> folder with the same name as it was stored in the server. It runs until the
> queue count is 0.
> 
> You could use tasks, but i found this to be better as it is easier to keep
> track of the progress.
> 
> 
> 
> [0]
> http://bazaar.launchpad.net/~sebikul/mundus/trunk/view/head:/.src/Index.module
> 

Argh! There is a sweet little Queue class in gb.data. I even wrote
documentation for it! And you keep using Private $aQueue As String[]? :-)

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list