Push a task into a lane.
| 97 | |
| 98 | //! Push a task into a lane. |
| 99 | void push( task* source, FastRandom& random ) { |
| 100 | // Lane selection is random. Each thread should keep a separate seed value. |
| 101 | unsigned idx; |
| 102 | for( ; ; ) { |
| 103 | idx = random.get() & (N-1); |
| 104 | spin_mutex::scoped_lock lock; |
| 105 | if( lock.try_acquire(lanes[idx].my_mutex) ) { |
| 106 | lanes[idx].my_queue.push_back(source); |
| 107 | set_one_bit( population, idx ); //TODO: avoid atomic op if the bit is already set |
| 108 | break; |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | //! Try finding and popping a task. |
| 114 | task* pop( unsigned& last_used_lane ) { |
nothing calls this directly
no test coverage detected