Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #1076

Re: pthread get/set specific for local buffers

From Mark <i@dontgetlotsofspamanymore.invalid>
Newsgroups comp.programming.threads
Subject Re: pthread get/set specific for local buffers
Date 2012-09-17 10:25 +0100
Message-ID <70rd581720us3jdjj55mp49mbntju25h0f@4ax.com> (permalink)
References <fdd5b92c-6ca1-4564-aedc-42b01c05cd37@googlegroups.com>

Show all headers | View raw


On Sun, 16 Sep 2012 09:55:50 -0700 (PDT), sinbad.sinbad@gmail.com
wrote:

>hi,
>
>In one of my program, there came a need where i should
>have a thread specific buffer, i found that pthread_key_t
>and pthread_getspecific() pthread_setspecific() family of
>functions are used exactly for that purpose, my question
>is it safe to use the above functions, are there any things
>i should keep in mind, finally is there any better solution
>for this.

It's quite safe to use these functions, otherwise they wouldn't be
there ;-)  The normal caveats apply: Avoid race conditions when
creating the key and remember to free memory when you have finished
with it.

I created a wrapper class to do all this for me.
-- 
(\__/)  M.
(='.'=) If a man stands in a forest and no woman is around
(")_(") is he still wrong?

Back to comp.programming.threads | Previous | NextPrevious in thread | Find similar


Thread

pthread get/set specific for local buffers sinbad.sinbad@gmail.com - 2012-09-16 09:55 -0700
  Re: pthread get/set specific for local buffers Mark <i@dontgetlotsofspamanymore.invalid> - 2012-09-17 10:25 +0100

csiph-web