curl-library
Re: living _with_ global variables
Date: Thu, 5 Jan 2006 09:01:15 +0100 (CET)
On Tue, 27 Dec 2005, Bryan Henderson wrote:
> libcurl already has that thread-unsafe global init function, so it's all set
> for this paradigm but for one thing: It doesn't do the reference count. It
> has a flag "I've been initialized." If that could be changed to "I've been
> initialized N times", and curl_global_init() conspicuously documented as
> thread-unsafe (to the greatest degree -- you must execute it when there is
> no other thread in the program doing anything, not just no other thread
> using libcurl), we'd have a solution to the modularity problem.
>
> The fail-safe global init in curl_easy_init() would have to get
> messier -- it would have to do its thing only if the init count is 0.
>
> This is kind of ugly compared to private contexts, especially in an
> object-oriented program, but it's really easy.
>
> For dynamically loaded libraries, I believe this isn't any better or
> worse than what we have today.
>
> Does this work? Have I missed something?
I think it'd work and it really shouldn't break any existing applications.
-- Commercial curl and libcurl Technical Support: http://haxx.se/curl.htmlReceived on 2006-01-05