markpasc (markpasc) wrote,

Using thread local storage

winget f'n'l spec #3, and good luck finding the differences.

I haven't entirely figured out how to get files to download to a particular place. It might be having a bad reaction with TLS.

Update 5:42pm: yeah, it was TLS. I had only defined struct options opt as thread-local, not declared it so.

I hadn't mentioned it before, but yeah, a little birdie clued me in that I don't have to reach down into wget's deep jungly reaches (yet! still!) if I declare opt using Windows thread-local storage, which means each thread gets its own struct options opt, which is exactly what I wanted. Last I said about it, I thought adding it as a parameter was still the way to go, but that was when I'd be having a, like, std::map<HANDLE,struct options*> threadOptions and fetching with threadOptions[GetCurrentThread()]. With TLS it already works and I can't argue with that.

My question: why does wget not close the file, but rather only flush it, if --output-document is specified? That's how I'm passing the filename in from the UI, so it looks like I have to close it myself to make sure it's closed. Luckily it's kept in opt too, so it's already done and appears to work, though I did crash winget a few minutes ago saving a file over another one. Not sure.

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened