| 212 | }; |
| 213 | |
| 214 | void concurrent_vector_base_v3::helper::extend_segment_table(concurrent_vector_base_v3 &v, concurrent_vector_base_v3::size_type start) { |
| 215 | if( start > segment_size(pointers_per_short_table) ) start = segment_size(pointers_per_short_table); |
| 216 | // If other threads are trying to set pointers in the short segment, wait for them to finish their |
| 217 | // assignments before we copy the short segment to the long segment. Note: grow_to_at_least depends on it |
| 218 | for( segment_index_t i = 0; segment_base(i) < start && v.my_segment == v.my_storage; i++ ){ |
| 219 | if(v.my_storage[i].load<relaxed>() == segment_not_used()) { |
| 220 | ITT_NOTIFY(sync_prepare, &v.my_storage[i]); |
| 221 | atomic_backoff backoff(true); |
| 222 | while( v.my_segment == v.my_storage && (v.my_storage[i].load<relaxed>() == segment_not_used()) ) |
| 223 | backoff.pause(); |
| 224 | ITT_NOTIFY(sync_acquired, &v.my_storage[i]); |
| 225 | } |
| 226 | } |
| 227 | if( v.my_segment != v.my_storage ) return; |
| 228 | |
| 229 | segment_t* new_segment_table = (segment_t*)NFS_Allocate( pointers_per_long_table, sizeof(segment_t), NULL ); |
| 230 | __TBB_ASSERT(new_segment_table, "NFS_Allocate should throws exception if it cannot allocate the requested storage, and not returns zero pointer" ); |
| 231 | std::uninitialized_fill_n(new_segment_table,size_t(pointers_per_long_table),segment_t()); //init newly allocated table |
| 232 | //TODO: replace with static assert |
| 233 | __TBB_STATIC_ASSERT(pointers_per_long_table >= pointers_per_short_table, "size of the big table should be not lesser than of the small one, as we copy values to it" ); |
| 234 | std::copy(v.my_storage, v.my_storage+pointers_per_short_table, new_segment_table);//copy values from old table, here operator= of segment_t is used |
| 235 | if( v.my_segment.compare_and_swap( new_segment_table, v.my_storage ) != v.my_storage ) |
| 236 | NFS_Free( new_segment_table ); |
| 237 | // else TODO: add ITT_NOTIFY signals for v.my_segment? |
| 238 | } |
| 239 | |
| 240 | concurrent_vector_base_v3::size_type concurrent_vector_base_v3::helper::enable_segment(concurrent_vector_base_v3 &v, concurrent_vector_base_v3::size_type k, concurrent_vector_base_v3::size_type element_size, |
| 241 | bool mark_as_not_used_on_failure ) { |
nothing calls this directly
no test coverage detected