133 unsigned int tableindex;
138 while(empty_slot.empty())
139 verrou.wait(cond_full);
141 tableindex = empty_slot.back();
145 if(tableindex >= table.size())
147 if( ! table[tableindex].empty)
152 table[tableindex].empty =
false;
153 table[tableindex].obj = std::move(one);
154 table[tableindex].index = next_index;
155 table[tableindex].flag = flag;
157 corres[next_index] = tableindex;
160 empty_slot.pop_back();
161 if(verrou.get_waiting_thread_count(cond_empty) > 0)
162 verrou.signal(cond_empty);
167 verrou.broadcast(cond_empty);
168 verrou.broadcast(cond_full);
176 std::unique_ptr<T> ret;
181 std::map<unsigned int, unsigned int>::iterator it = corres.begin();
187 if(it != corres.end())
189 if(it->first < lowest_index)
196 if(it->second >= table.size())
198 if(table[it->second].empty)
200 if( ! table[it->second].obj)
205 ret = std::move(table[it->second].obj);
206 slot = table[it->second].index;
207 flag = table[it->second].flag;
208 table[it->second].empty =
true;
210 if(lowest_index != slot)
216 empty_slot.push_back(it->second);
219 if(verrou.get_waiting_thread_count(cond_full) > 0)
220 verrou.signal(cond_full);
227 verrou.wait(cond_empty);
236 verrou.broadcast(cond_empty);
237 verrou.broadcast(cond_full);