Put a token into the buffer. If task information was placed into buffer, returns true; otherwise returns false, informing the caller to create and spawn a task. If input buffer owned by thread-bound filter and the item at low_token was not valid, issue a V() If the input_buffer is owned by a successor to a thread-bound filter, the force_put parameter should
| 137 | in the buffer. |
| 138 | */ |
| 139 | bool put_token( task_info& info_, bool force_put = false ) { |
| 140 | { |
| 141 | info_.is_valid = true; |
| 142 | spin_mutex::scoped_lock lock( array_mutex ); |
| 143 | Token token; |
| 144 | bool was_empty = !array[low_token&(array_size-1)].is_valid; |
| 145 | if( is_ordered ) { |
| 146 | if( !info_.my_token_ready ) { |
| 147 | info_.my_token = high_token++; |
| 148 | info_.my_token_ready = true; |
| 149 | } |
| 150 | token = info_.my_token; |
| 151 | } else |
| 152 | token = high_token++; |
| 153 | __TBB_ASSERT( (tokendiff_t)(token-low_token)>=0, NULL ); |
| 154 | if( token!=low_token || is_bound || force_put ) { |
| 155 | // Trying to put token that is beyond low_token. |
| 156 | // Need to wait until low_token catches up before dispatching. |
| 157 | if( token-low_token>=array_size ) |
| 158 | grow( token-low_token+1 ); |
| 159 | ITT_NOTIFY( sync_releasing, this ); |
| 160 | array[token&(array_size-1)] = info_; |
| 161 | if(was_empty && is_bound) { |
| 162 | sema_V(); |
| 163 | } |
| 164 | return true; |
| 165 | } |
| 166 | } |
| 167 | return false; |
| 168 | } |
| 169 | |
| 170 | //! Note that processing of a token is finished. |
| 171 | /** Fires up processing of the next token, if processing was deferred. */ |
no outgoing calls
no test coverage detected