Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::internal::task_stream< Levels > Class Template Reference

The container for "fairness-oriented" aka "enqueued" tasks. More...

#include <task_stream.h>

Inheritance diagram for tbb::internal::task_stream< Levels >:
Collaboration diagram for tbb::internal::task_stream< Levels >:

Public Member Functions

 task_stream ()
 
void initialize (unsigned n_lanes)
 
 ~task_stream ()
 
void push (task *source, int level, FastRandom &random)
 Push a task into a lane. More...
 
taskpop (int level, unsigned &last_used_lane)
 Try finding and popping a task. More...
 
bool empty (int level)
 Checks existence of a task. More...
 
intptr_t drain ()
 Destroys all remaining tasks in every lane. Returns the number of destroyed tasks. More...
 
 task_stream ()
 
void initialize (unsigned n_lanes)
 
 ~task_stream ()
 
bool try_push (task *source, int level, unsigned lane_idx)
 Returns true on successful push, otherwise - false. More...
 
template<typename lane_selector_t >
void push (task *source, int level, const lane_selector_t &next_lane)
 Push a task into a lane. Lane selection is performed by passed functor. More...
 
tasktry_pop (int level, unsigned lane_idx)
 Returns pointer to task on successful pop, otherwise - NULL. More...
 
template<typename lane_selector_t >
taskpop (int level, const lane_selector_t &next_lane)
 
tasklook_specific (__TBB_ISOLATION_ARG(task_stream_base::lane_t::queue_base_t &queue, isolation_tag isolation))
 
taskpop_specific (int level, __TBB_ISOLATION_ARG(unsigned &last_used_lane, isolation_tag isolation))
 Try finding and popping a related task. More...
 
bool empty (int level)
 Checks existence of a task. More...
 
intptr_t drain ()
 Destroys all remaining tasks in every lane. Returns the number of destroyed tasks. More...
 

Private Types

typedef queue_and_mutex< task *, spin_mutexlane_t
 
typedef task_stream_accessor< accessor >::lane_t lane_t
 

Private Attributes

population_t population [Levels]
 
padded< lane_t > * lanes [Levels]
 
unsigned N
 

Additional Inherited Members

- Protected Types inherited from tbb::internal::task_stream_accessor< accessor >
typedef queue_and_mutex< task *, spin_mutexlane_t
 
- Protected Types inherited from tbb::internal::task_stream_base
typedef queue_and_mutex< task *, spin_mutexlane_t
 
- Protected Member Functions inherited from tbb::internal::task_stream_accessor< accessor >
taskget_item (lane_t::queue_base_t &queue)
 
- Private Member Functions inherited from tbb::internal::no_copy
 no_copy ()
 Allow default construction. More...
 

Detailed Description

template<int Levels>
class tbb::internal::task_stream< Levels >

The container for "fairness-oriented" aka "enqueued" tasks.

Definition at line 73 of file task_stream.h.

Member Typedef Documentation

◆ lane_t [1/2]

template<int Levels>
typedef queue_and_mutex<task*, spin_mutex> tbb::internal::task_stream< Levels >::lane_t
private

Definition at line 74 of file task_stream.h.

◆ lane_t [2/2]

template<int Levels>
typedef task_stream_accessor<accessor>::lane_t tbb::internal::task_stream< Levels >::lane_t
private

Definition at line 166 of file task_stream_extended.h.

Constructor & Destructor Documentation

◆ task_stream() [1/2]

template<int Levels>
tbb::internal::task_stream< Levels >::task_stream ( )
inline

Definition at line 80 of file task_stream.h.

80  : N() {
81  for(int level = 0; level < Levels; level++) {
82  population[level] = 0;
83  lanes[level] = NULL;
84  }
85  }
padded< lane_t > * lanes[Levels]
Definition: task_stream.h:76
population_t population[Levels]
Definition: task_stream.h:75

◆ ~task_stream() [1/2]

template<int Levels>
tbb::internal::task_stream< Levels >::~task_stream ( )
inline

Definition at line 99 of file task_stream.h.

99  {
100  for(int level = 0; level < Levels; level++)
101  if (lanes[level]) delete[] lanes[level];
102  }
padded< lane_t > * lanes[Levels]
Definition: task_stream.h:76

◆ task_stream() [2/2]

template<int Levels>
tbb::internal::task_stream< Levels >::task_stream ( )
inline

Definition at line 172 of file task_stream_extended.h.

172  : N() {
173  for(int level = 0; level < Levels; level++) {
174  population[level] = 0;
175  lanes[level] = NULL;
176  }
177  }
padded< lane_t > * lanes[Levels]
Definition: task_stream.h:76
population_t population[Levels]
Definition: task_stream.h:75

◆ ~task_stream() [2/2]

template<int Levels>
tbb::internal::task_stream< Levels >::~task_stream ( )
inline

Definition at line 191 of file task_stream_extended.h.

191  {
192  for(int level = 0; level < Levels; level++)
193  if (lanes[level]) delete[] lanes[level];
194  }
padded< lane_t > * lanes[Levels]
Definition: task_stream.h:76

Member Function Documentation

◆ drain() [1/2]

template<int Levels>
intptr_t tbb::internal::task_stream< Levels >::drain ( )
inline

Destroys all remaining tasks in every lane. Returns the number of destroyed tasks.

Tasks are not executed, because it would potentially create more tasks at a late stage. The scheduler is really expected to execute all tasks before task_stream destruction.

Definition at line 149 of file task_stream.h.

149  {
150  intptr_t result = 0;
151  for(int level = 0; level < Levels; level++)
152  for(unsigned i=0; i<N; ++i) {
153  lane_t& lane = lanes[level][i];
154  spin_mutex::scoped_lock lock(lane.my_mutex);
155  for(lane_t::queue_base_t::iterator it=lane.my_queue.begin();
156  it!=lane.my_queue.end(); ++it, ++result)
157  {
158  __TBB_ASSERT( is_bit_set( population[level], i ), NULL );
159  task* t = *it;
160  tbb::task::destroy(*t);
161  }
162  lane.my_queue.clear();
163  clear_one_bit( population[level], i );
164  }
165  return result;
166  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
padded< lane_t > * lanes[Levels]
Definition: task_stream.h:76
queue_and_mutex< task *, spin_mutex > lane_t
Definition: task_stream.h:74
population_t population[Levels]
Definition: task_stream.h:75
friend class scoped_lock
Definition: spin_mutex.h:180
bool is_bit_set(population_t val, int pos)
Definition: task_stream.h:65
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void * lock
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task * task
void clear_one_bit(population_t &dest, int pos)
Definition: task_stream.h:59

Referenced by tbb::internal::arena::free_arena().

Here is the caller graph for this function:

◆ drain() [2/2]

template<int Levels>
intptr_t tbb::internal::task_stream< Levels >::drain ( )
inline

Destroys all remaining tasks in every lane. Returns the number of destroyed tasks.

Tasks are not executed, because it would potentially create more tasks at a late stage. The scheduler is really expected to execute all tasks before task_stream destruction.

Definition at line 300 of file task_stream_extended.h.

300  {
301  intptr_t result = 0;
302  for(int level = 0; level < Levels; level++)
303  for(unsigned i=0; i<N; ++i) {
304  lane_t& lane = lanes[level][i];
305  spin_mutex::scoped_lock lock(lane.my_mutex);
306  for(typename lane_t::queue_base_t::iterator it=lane.my_queue.begin();
307  it!=lane.my_queue.end(); ++it, ++result)
308  {
309  __TBB_ASSERT( is_bit_set( population[level], i ), NULL );
310  task* t = *it;
311  tbb::task::destroy(*t);
312  }
313  lane.my_queue.clear();
314  clear_one_bit( population[level], i );
315  }
316  return result;
317  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
padded< lane_t > * lanes[Levels]
Definition: task_stream.h:76
queue_and_mutex< task *, spin_mutex > lane_t
Definition: task_stream.h:74
population_t population[Levels]
Definition: task_stream.h:75
friend class scoped_lock
Definition: spin_mutex.h:180
bool is_bit_set(population_t val, int pos)
Definition: task_stream.h:65
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void * lock
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task * task
void clear_one_bit(population_t &dest, int pos)
Definition: task_stream.h:59

◆ empty() [1/2]

template<int Levels>
bool tbb::internal::task_stream< Levels >::empty ( int  level)
inline

Checks existence of a task.

Definition at line 142 of file task_stream.h.

142  {
143  return !population[level];
144  }
population_t population[Levels]
Definition: task_stream.h:75

Referenced by tbb::internal::arena::has_enqueued_tasks(), tbb::internal::arena::is_out_of_work(), tbb::internal::task_stream< num_priority_levels >::pop(), tbb::internal::task_stream< num_priority_levels >::pop_specific(), and tbb::internal::arena::restore_priority_if_need().

Here is the caller graph for this function:

◆ empty() [2/2]

template<int Levels>
bool tbb::internal::task_stream< Levels >::empty ( int  level)
inline

Checks existence of a task.

Definition at line 293 of file task_stream_extended.h.

293  {
294  return !population[level];
295  }
population_t population[Levels]
Definition: task_stream.h:75

◆ initialize() [1/2]

template<int Levels>
void tbb::internal::task_stream< Levels >::initialize ( unsigned  n_lanes)
inline

Definition at line 87 of file task_stream.h.

87  {
88  const unsigned max_lanes = sizeof(population_t) * CHAR_BIT;
89 
90  N = n_lanes>=max_lanes ? max_lanes : n_lanes>2 ? 1<<(__TBB_Log2(n_lanes-1)+1) : 2;
91  __TBB_ASSERT( N==max_lanes || N>=n_lanes && ((N-1)&N)==0, "number of lanes miscalculated");
92  __TBB_ASSERT( N <= sizeof(population_t) * CHAR_BIT, NULL );
93  for(int level = 0; level < Levels; level++) {
94  lanes[level] = new padded<lane_t>[N];
95  __TBB_ASSERT( !population[level], NULL );
96  }
97  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
padded< lane_t > * lanes[Levels]
Definition: task_stream.h:76
uintptr_t population_t
Definition: task_stream.h:50
population_t population[Levels]
Definition: task_stream.h:75
intptr_t __TBB_Log2(uintptr_t x)
Definition: tbb_machine.h:864

Referenced by tbb::internal::arena::arena().

Here is the caller graph for this function:

◆ initialize() [2/2]

template<int Levels>
void tbb::internal::task_stream< Levels >::initialize ( unsigned  n_lanes)
inline

Definition at line 179 of file task_stream_extended.h.

179  {
180  const unsigned max_lanes = sizeof(population_t) * CHAR_BIT;
181 
182  N = n_lanes>=max_lanes ? max_lanes : n_lanes>2 ? 1<<(__TBB_Log2(n_lanes-1)+1) : 2;
183  __TBB_ASSERT( N==max_lanes || N>=n_lanes && ((N-1)&N)==0, "number of lanes miscalculated");
184  __TBB_ASSERT( N <= sizeof(population_t) * CHAR_BIT, NULL );
185  for(int level = 0; level < Levels; level++) {
186  lanes[level] = new padded<lane_t>[N];
187  __TBB_ASSERT( !population[level], NULL );
188  }
189  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
padded< lane_t > * lanes[Levels]
Definition: task_stream.h:76
uintptr_t population_t
Definition: task_stream.h:50
population_t population[Levels]
Definition: task_stream.h:75
intptr_t __TBB_Log2(uintptr_t x)
Definition: tbb_machine.h:864

◆ look_specific()

template<int Levels>
task* tbb::internal::task_stream< Levels >::look_specific ( __TBB_ISOLATION_ARG(task_stream_base::lane_t::queue_base_t &queue, isolation_tag isolation)  )
inline

Definition at line 249 of file task_stream_extended.h.

249  {
250  __TBB_ASSERT( !queue.empty(), NULL );
251  // TODO: add a worst-case performance test and consider an alternative container with better
252  // performance for isolation search.
253  typename lane_t::queue_base_t::iterator curr = queue.end();
254  do {
255  // TODO: consider logic from get_task to simplify the code.
256  task* result = *--curr;
257  if( result __TBB_ISOLATION_EXPR( && result->prefix().isolation == isolation ) ) {
258  if( queue.end() - curr == 1 )
259  queue.pop_back(); // a little of housekeeping along the way
260  else
261  *curr = 0; // grabbing task with the same isolation
262  // TODO: move one of the container's ends instead if the task has been found there
263  return result;
264  }
265  } while( curr != queue.begin() );
266  return NULL;
267  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
#define __TBB_ISOLATION_EXPR(isolation)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task * task

Referenced by tbb::internal::task_stream< num_priority_levels >::pop_specific().

Here is the caller graph for this function:

◆ pop() [1/2]

template<int Levels>
task* tbb::internal::task_stream< Levels >::pop ( int  level,
unsigned &  last_used_lane 
)
inline

Try finding and popping a task.

Definition at line 120 of file task_stream.h.

120  {
121  task* result = NULL;
122  // Lane selection is round-robin. Each thread should keep its last used lane.
123  unsigned idx = (last_used_lane+1)&(N-1);
124  for( ; population[level]; idx=(idx+1)&(N-1) ) {
125  if( is_bit_set( population[level], idx ) ) {
126  lane_t& lane = lanes[level][idx];
128  if( lock.try_acquire(lane.my_mutex) && !lane.my_queue.empty() ) {
129  result = lane.my_queue.front();
130  lane.my_queue.pop_front();
131  if( lane.my_queue.empty() )
132  clear_one_bit( population[level], idx );
133  break;
134  }
135  }
136  }
137  last_used_lane = idx;
138  return result;
139  }
padded< lane_t > * lanes[Levels]
Definition: task_stream.h:76
queue_and_mutex< task *, spin_mutex > lane_t
Definition: task_stream.h:74
population_t population[Levels]
Definition: task_stream.h:75
friend class scoped_lock
Definition: spin_mutex.h:180
bool is_bit_set(population_t val, int pos)
Definition: task_stream.h:65
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void * lock
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task * task
void clear_one_bit(population_t &dest, int pos)
Definition: task_stream.h:59

◆ pop() [2/2]

template<int Levels>
template<typename lane_selector_t >
task* tbb::internal::task_stream< Levels >::pop ( int  level,
const lane_selector_t &  next_lane 
)
inline

Try finding and popping a task using passed functor for lane selection. Last used lane is updated inside lane selector.

Definition at line 238 of file task_stream_extended.h.

238  {
239  task* popped = NULL;
240  unsigned lane = 0;
241  do {
242  lane = next_lane( /*out_of=*/N );
243  __TBB_ASSERT( lane < N, "Incorrect lane index." );
244  } while( !empty( level ) && !(popped = try_pop( level, lane )) );
245  return popped;
246  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
bool empty(int level)
Checks existence of a task.
Definition: task_stream.h:142
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task * task
task * try_pop(int level, unsigned lane_idx)
Returns pointer to task on successful pop, otherwise - NULL.

◆ pop_specific()

template<int Levels>
task* tbb::internal::task_stream< Levels >::pop_specific ( int  level,
__TBB_ISOLATION_ARG(unsigned &last_used_lane, isolation_tag isolation)   
)
inline

Try finding and popping a related task.

Definition at line 270 of file task_stream_extended.h.

270  {
271  task* result = NULL;
272  // Lane selection is round-robin in backward direction.
273  unsigned idx = last_used_lane & (N-1);
274  do {
275  if( is_bit_set( population[level], idx ) ) {
276  lane_t& lane = lanes[level][idx];
278  if( lock.try_acquire(lane.my_mutex) && !lane.my_queue.empty() ) {
279  result = look_specific( __TBB_ISOLATION_ARG(lane.my_queue, isolation) );
280  if( lane.my_queue.empty() )
281  clear_one_bit( population[level], idx );
282  if( result )
283  break;
284  }
285  }
286  idx=(idx-1)&(N-1);
287  } while( !empty(level) && idx != last_used_lane );
288  last_used_lane = idx;
289  return result;
290  }
padded< lane_t > * lanes[Levels]
Definition: task_stream.h:76
queue_and_mutex< task *, spin_mutex > lane_t
Definition: task_stream.h:74
#define __TBB_ISOLATION_ARG(arg1, isolation)
population_t population[Levels]
Definition: task_stream.h:75
bool empty(int level)
Checks existence of a task.
Definition: task_stream.h:142
friend class scoped_lock
Definition: spin_mutex.h:180
bool is_bit_set(population_t val, int pos)
Definition: task_stream.h:65
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void * lock
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task * task
void clear_one_bit(population_t &dest, int pos)
Definition: task_stream.h:59
task * look_specific(__TBB_ISOLATION_ARG(task_stream_base::lane_t::queue_base_t &queue, isolation_tag isolation))

◆ push() [1/2]

template<int Levels>
void tbb::internal::task_stream< Levels >::push ( task source,
int  level,
FastRandom random 
)
inline

Push a task into a lane.

Definition at line 105 of file task_stream.h.

105  {
106  // Lane selection is random. Each thread should keep a separate seed value.
107  unsigned idx;
108  for( ; ; ) {
109  idx = random.get() & (N-1);
111  if( lock.try_acquire(lanes[level][idx].my_mutex) ) {
112  lanes[level][idx].my_queue.push_back(source);
113  set_one_bit( population[level], idx ); //TODO: avoid atomic op if the bit is already set
114  break;
115  }
116  }
117  }
void set_one_bit(population_t &dest, int pos)
Definition: task_stream.h:53
padded< lane_t > * lanes[Levels]
Definition: task_stream.h:76
population_t population[Levels]
Definition: task_stream.h:75
friend class scoped_lock
Definition: spin_mutex.h:180
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void * lock

Referenced by tbb::internal::arena::enqueue_task().

Here is the caller graph for this function:

◆ push() [2/2]

template<int Levels>
template<typename lane_selector_t >
void tbb::internal::task_stream< Levels >::push ( task source,
int  level,
const lane_selector_t &  next_lane 
)
inline

Push a task into a lane. Lane selection is performed by passed functor.

Definition at line 210 of file task_stream_extended.h.

210  {
211  bool succeed = false;
212  unsigned lane = 0;
213  do {
214  lane = next_lane( /*out_of=*/N );
215  __TBB_ASSERT( lane < N, "Incorrect lane index." );
216  } while( ! (succeed = try_push( source, level, lane )) );
217  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
bool try_push(task *source, int level, unsigned lane_idx)
Returns true on successful push, otherwise - false.

◆ try_pop()

template<int Levels>
task* tbb::internal::task_stream< Levels >::try_pop ( int  level,
unsigned  lane_idx 
)
inline

Returns pointer to task on successful pop, otherwise - NULL.

Definition at line 220 of file task_stream_extended.h.

220  {
221  __TBB_ASSERT( 0 <= level && level < Levels, "Incorrect lane level specified." );
222  if( !is_bit_set( population[level], lane_idx ) )
223  return NULL;
224  task* result = NULL;
225  lane_t& lane = lanes[level][lane_idx];
227  if( lock.try_acquire( lane.my_mutex ) && !lane.my_queue.empty() ) {
228  result = this->get_item( lane.my_queue );
229  if( lane.my_queue.empty() )
230  clear_one_bit( population[level], lane_idx );
231  }
232  return result;
233  }
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
padded< lane_t > * lanes[Levels]
Definition: task_stream.h:76
queue_and_mutex< task *, spin_mutex > lane_t
Definition: task_stream.h:74
population_t population[Levels]
Definition: task_stream.h:75
friend class scoped_lock
Definition: spin_mutex.h:180
task * get_item(lane_t::queue_base_t &queue)
bool is_bit_set(population_t val, int pos)
Definition: task_stream.h:65
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void * lock
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task * task
void clear_one_bit(population_t &dest, int pos)
Definition: task_stream.h:59

Referenced by tbb::internal::task_stream< num_priority_levels >::pop().

Here is the caller graph for this function:

◆ try_push()

template<int Levels>
bool tbb::internal::task_stream< Levels >::try_push ( task source,
int  level,
unsigned  lane_idx 
)
inline

Returns true on successful push, otherwise - false.

Definition at line 197 of file task_stream_extended.h.

197  {
198  __TBB_ASSERT( 0 <= level && level < Levels, "Incorrect lane level specified." );
200  if( lock.try_acquire( lanes[level][lane_idx].my_mutex ) ) {
201  lanes[level][lane_idx].my_queue.push_back( source );
202  set_one_bit( population[level], lane_idx ); // TODO: avoid atomic op if the bit is already set
203  return true;
204  }
205  return false;
206  }
void set_one_bit(population_t &dest, int pos)
Definition: task_stream.h:53
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
padded< lane_t > * lanes[Levels]
Definition: task_stream.h:76
population_t population[Levels]
Definition: task_stream.h:75
friend class scoped_lock
Definition: spin_mutex.h:180
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void * lock

Referenced by tbb::internal::task_stream< num_priority_levels >::push().

Here is the caller graph for this function:

Member Data Documentation

◆ lanes

◆ N

◆ population


The documentation for this class was generated from the following files:

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

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.