Boost logo

Boost :

Subject: [boost] thread_specific_ptr prototype (was: Re: [thread] thread_specific_ptr performance)
From: Stefan Strasser (strasser_at_[hidden])
Date: 2010-01-13 09:08:29

Am Tuesday 12 January 2010 21:39:16 schrieb vicente.botet:
> In order to follow the discussion do you agree to post a clear proposal
> using your pages design?

the "pages" proposal was a result of our misunderstanding, I think a
vector-based implementation is sufficient.

here's a prototype implementation:

it implements all functions of a thread_specific_ptr except for custom cleanup
functions (for now).

below is the result of operator*.

thread_specific_ptr time complexities:

constructor: constant
destructor: constant average, occasional vector reallocation
operator*: constant
operator->: constant
release(): constant
get(): constant
reset(): undefined. operations by the tss code itself are constant average,
but it may call a user-supplied destructor or pthread functions.

it also fixes the bug I posted in a previous mail.

prototype::thread_specific_ptr<int> ptr;
int f(){
  return *ptr;

        pushl %ebp
        movl %gs:_ZN5boost9prototype6detail10tss_vectorE_at_NTPOFF, %edx
        movl ptr+4, %eax
        movl %esp, %ebp
        popl %ebp
        movl (%edx), %edx
        leal (%eax,%eax,2), %eax
        movl (%edx,%eax,4), %eax
        movl (%eax), %eax

Boost list run by bdawes at, gregod at, cpdaniel at, john at