[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] Sharing per-thread resources between connections

From: Carlos Eduardo Moreira dos Santos
Subject: Re: [libmicrohttpd] Sharing per-thread resources between connections
Date: Tue, 19 Aug 2014 01:45:15 -0300

I realized that pthread_once runs only once per execution instead of once per thread as I need. After reading libmicrohttpd and pthread docs, it seems that it is not possible to add any other thread initialization function besides the one in specified pthread_create. I could only find pthread_get/setspecific (and NULL value checking) as a solution for thread-local variable initialization. Please, let me know if I am going into the right direction.

Carlos Eduardo

On Tue, Aug 12, 2014 at 6:20 PM, Christian Grothoff <address@hidden> wrote:
The real answer is that _you_ must measure it --- especially since the
real answer will depend on your platform, application and performance
requirements.  I _suspect_ that it won't matter either way.

Happy hacking!


On 08/12/2014 10:36 PM, Carlos Eduardo Moreira dos Santos wrote:
> __thread keyword is simple to use, but I have to open one socket per
> thread, so I used pthread_once and also pthread_key_create to close it. The
> only disadvantage I noticed is running pthread_once in every access handler
> callback call. I don't know the details, but pthread_once should be fast
> enough to discard my code, isn't it?
> Best,
> Carlos Eduardo
> On Thu, Jul 3, 2014 at 5:05 AM, Christian Grothoff <address@hidden>
> wrote:
>> Well, pthread_key_create() also works, I guess, but I was thinking about
>> a slightly more lightweight method:
>> But both should work, and the best choice may really depend on your
>> application and its intended environment.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]