Daemon icon indicating copy to clipboard operation
Daemon copied to clipboard

Curl: add a thread for http downloads

Open necessarily-equal opened this issue 3 years ago • 3 comments

The thread uses pooling to keep CPU usage low. I've seen 2MB download speed over my 4G connection.

necessarily-equal avatar Jul 22 '22 00:07 necessarily-equal

I'm not sure why, but this can bork the loading screen progress bar.

necessarily-equal avatar Jul 22 '22 01:07 necessarily-equal

There's really no need to use a thread. I found a perfect place to call CL_WWWDownload - in Com_Frame, if you set a really low framerate then the main thread wakes up every 50 ms and pumps the event loop (here). So by invoking the download loop there we could avoid any problems caused by setting a low framerate when minimized.

slipher avatar Jul 22 '22 03:07 slipher

To get rid of the thread-safety problem this version has, I can make DL_DownloadStatus return the progress (return a struct that contains {status, count, max}) and get rid of the cvars. I think it's a bit better to have this in a thread and to get rid of the cvars.

necessarily-equal avatar Jul 22 '22 18:07 necessarily-equal