Intel Threading Building Blocks 2.1 for Open Source

Classes | Enumerations | Functions

tbb::internal Namespace Reference

Classes

class  allocate_additional_child_of_proxy
class  atomic_backoff
 Class that implements exponential backoff. More...
class  critical_section_v4
class  function_task
struct  reverse
class  task_group_base
class  task_handle_task
class  task_scheduler_observer_v3
struct  type_with_alignment
struct  type_with_alignment< 1 >
struct  type_with_alignment< 2 >
struct  type_with_alignment< 4 >
struct  type_with_alignment< 8 >

Enumerations

enum  exception_id {
  eid_bad_alloc = 1, eid_bad_last_alloc, eid_nonpositive_step, eid_out_of_range,
  eid_segment_range_error, eid_index_range_error, eid_missing_wait, eid_invalid_multiple_scheduling,
  eid_improper_lock, eid_possible_deadlock, eid_operation_not_permitted, eid_condvar_wait_failed,
  eid_invalid_load_factor, eid_invalid_buckets_number, eid_invalid_swap, eid_reservation_length_error,
  eid_invalid_key, eid_max
}

Functions

template<size_t S, typename T >
T __TBB_CompareAndSwapGeneric (volatile void *ptr, T value, T comparand)
template<>
uint8_t __TBB_CompareAndSwapGeneric< 1, uint8_t > (volatile void *ptr, uint8_t value, uint8_t comparand)
template<>
uint16_t __TBB_CompareAndSwapGeneric< 2, uint16_t > (volatile void *ptr, uint16_t value, uint16_t comparand)
template<>
uint32_t __TBB_CompareAndSwapGeneric< 4, uint32_t > (volatile void *ptr, uint32_t value, uint32_t comparand)
template<>
uint64_t __TBB_CompareAndSwapGeneric< 8, uint64_t > (volatile void *ptr, uint64_t value, uint64_t comparand)
template<size_t S, typename T >
T __TBB_FetchAndAddGeneric (volatile void *ptr, T addend)
template<size_t S, typename T >
T __TBB_FetchAndStoreGeneric (volatile void *ptr, T value)
template<size_t S, typename T >
T __TBB_MaskedCompareAndSwap (volatile T *ptr, T value, T comparand)
template<typename T , typename U >
void spin_wait_until_eq (const volatile T &location, const U value)
 Spin UNTIL the value of the variable is equal to a given value.
template<typename T , typename U >
void spin_wait_while_eq (const volatile T &location, U value)
 Spin WHILE the value of the variable is equal to a given value.
void throw_bad_last_alloc_exception_v4 ()
 Obsolete.
void throw_exception (exception_id eid)
 Versionless convenience wrapper for throw_exception_v4().
void throw_exception_v4 (exception_id)
 Gathers all throw operators in one place.

Enumeration Type Documentation

Enumerator:
eid_bad_alloc 
eid_bad_last_alloc 
eid_nonpositive_step 
eid_out_of_range 
eid_segment_range_error 
eid_index_range_error 
eid_missing_wait 
eid_invalid_multiple_scheduling 
eid_improper_lock 
eid_possible_deadlock 
eid_operation_not_permitted 
eid_condvar_wait_failed 
eid_invalid_load_factor 
eid_invalid_buckets_number 
eid_invalid_swap 
eid_reservation_length_error 
eid_invalid_key 
eid_max 

The last enumerator tracks the number of defined IDs. It must remain the last one.

When adding new IDs, place them immediately _before_ this comment (that is _after_ all the existing IDs. NEVER insert new IDs between the existing ones.

Definition at line 83 of file tbb_exception.h.

                  {
    eid_bad_alloc = 1,
    eid_bad_last_alloc,
    eid_nonpositive_step,
    eid_out_of_range,
    eid_segment_range_error,
    eid_index_range_error,
    eid_missing_wait,
    eid_invalid_multiple_scheduling,
    eid_improper_lock,
    eid_possible_deadlock,
    eid_operation_not_permitted,
    eid_condvar_wait_failed,
    eid_invalid_load_factor,
    eid_invalid_buckets_number,
    eid_invalid_swap,
    eid_reservation_length_error,
    eid_invalid_key,

    eid_max
};


Function Documentation

template<size_t S, typename T >
T tbb::internal::__TBB_CompareAndSwapGeneric ( volatile void *  ptr,
T  value,
T  comparand 
) [inline]

Definition at line 217 of file tbb_machine.h.

References T.

                                                                                 { 
    return __TBB_CompareAndSwapW((T *)ptr,value,comparand);
}

template<>
uint8_t tbb::internal::__TBB_CompareAndSwapGeneric< 1, uint8_t > ( volatile void *  ptr,
uint8_t  value,
uint8_t  comparand 
) [inline]
template<>
uint16_t tbb::internal::__TBB_CompareAndSwapGeneric< 2, uint16_t > ( volatile void *  ptr,
uint16_t  value,
uint16_t  comparand 
) [inline]
template<>
uint32_t tbb::internal::__TBB_CompareAndSwapGeneric< 4, uint32_t > ( volatile void *  ptr,
uint32_t  value,
uint32_t  comparand 
) [inline]
template<>
uint64_t tbb::internal::__TBB_CompareAndSwapGeneric< 8, uint64_t > ( volatile void *  ptr,
uint64_t  value,
uint64_t  comparand 
) [inline]
template<size_t S, typename T >
T tbb::internal::__TBB_FetchAndAddGeneric ( volatile void *  ptr,
T  addend 
) [inline]

Definition at line 250 of file tbb_machine.h.

References tbb::internal::atomic_backoff::pause(), and T.

                                                                 {
    atomic_backoff b;
    T result;
    for(;;) {
        result = *reinterpret_cast<volatile T *>(ptr);
        // __TBB_CompareAndSwapGeneric presumed to have full fence. 
        if( __TBB_CompareAndSwapGeneric<S,T> ( ptr, result+addend, result )==result ) 
            break;
        b.pause();
    }
    return result;
}

template<size_t S, typename T >
T tbb::internal::__TBB_FetchAndStoreGeneric ( volatile void *  ptr,
T  value 
) [inline]

Definition at line 264 of file tbb_machine.h.

References tbb::internal::atomic_backoff::pause(), and T.

                                                                  {
    atomic_backoff b;
    T result;
    for(;;) {
        result = *reinterpret_cast<volatile T *>(ptr);
        // __TBB_CompareAndSwapGeneric presumed to have full fence.
        if( __TBB_CompareAndSwapGeneric<S,T> ( ptr, value, result )==result ) 
            break;
        b.pause();
    }
    return result;
}

template<size_t S, typename T >
T tbb::internal::__TBB_MaskedCompareAndSwap ( volatile T ptr,
T  value,
T  comparand 
) [inline]

Definition at line 191 of file tbb_machine.h.

References tbb::internal::atomic_backoff::pause(), S, and T.

                                                                             {
    volatile uint32_t * base = (uint32_t*)( (uintptr_t)ptr & ~(uintptr_t)0x3 );
#if __TBB_BIG_ENDIAN
    const uint8_t bitoffset = uint8_t( 8*( 4-S - (uintptr_t(ptr) & 0x3) ) );
#else
    const uint8_t bitoffset = uint8_t( 8*((uintptr_t)ptr & 0x3) );
#endif
    const uint32_t mask = ( (1<<(S*8)) - 1 )<<bitoffset;
    atomic_backoff b;
    uint32_t result;
    for(;;) {
        result = *base; // reload the base value which might change during the pause
        uint32_t old_value = ( result & ~mask ) | ( comparand << bitoffset );
        uint32_t new_value = ( result & ~mask ) | ( value << bitoffset );
        // __TBB_CompareAndSwap4 presumed to have full fence. 
        result = __TBB_CompareAndSwap4( base, new_value, old_value );
        if(  result==old_value               // CAS succeeded
          || ((result^old_value)&mask)!=0 )  // CAS failed and the bits of interest have changed
            break;
        else                                 // CAS failed but the bits of interest left unchanged
            b.pause();
    }
    return T((result & mask) >> bitoffset);
}

template<typename T , typename U >
void tbb::internal::spin_wait_until_eq ( const volatile T location,
const U  value 
)

T and U should be comparable types.

Definition at line 182 of file tbb_machine.h.

References tbb::internal::atomic_backoff::pause().

                                                                     {
    atomic_backoff backoff;
    while( location!=value ) backoff.pause();
}

template<typename T , typename U >
void tbb::internal::spin_wait_while_eq ( const volatile T location,
value 
)

T and U should be comparable types.

Definition at line 174 of file tbb_machine.h.

References tbb::internal::atomic_backoff::pause().

                                                               {
    atomic_backoff backoff;
    while( location==value ) backoff.pause();
}

void tbb::internal::throw_bad_last_alloc_exception_v4 (  ) 
void tbb::internal::throw_exception ( exception_id  eid  )  [inline]
void tbb::internal::throw_exception_v4 ( exception_id   ) 

Its purpose is to minimize code bloat that can be caused by throw operators scattered in multiple places, especially in templates.

Referenced by throw_exception().


Copyright © 2005-2010 Intel Corporation. All Rights Reserved.

Licensed under the GNU General Public License 2 with the runtime exception.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.