132 unsigned int tableindex;
137 while(empty_slot.empty())
138 verrou.wait(cond_full);
140 tableindex = empty_slot.back();
144 if(tableindex >= table.size())
146 if( ! table[tableindex].empty)
151 table[tableindex].empty =
false;
152 table[tableindex].obj = std::move(one);
153 table[tableindex].index = next_index;
154 table[tableindex].flag = flag;
156 corres[next_index] = tableindex;
159 empty_slot.pop_back();
160 if(verrou.get_waiting_thread_count(cond_empty) > 0)
161 verrou.signal(cond_empty);
166 verrou.broadcast(cond_empty);
167 verrou.broadcast(cond_full);
175 std::unique_ptr<T> ret;
180 std::map<unsigned int, unsigned int>::iterator it = corres.begin();
186 if(it != corres.end())
188 if(it->first < lowest_index)
195 if(it->second >= table.size())
197 if(table[it->second].empty)
199 if( ! table[it->second].obj)
204 ret = std::move(table[it->second].obj);
205 slot = table[it->second].index;
206 flag = table[it->second].flag;
207 table[it->second].empty =
true;
209 if(lowest_index != slot)
215 empty_slot.push_back(it->second);
218 if(verrou.get_waiting_thread_count(cond_full) > 0)
219 verrou.signal(cond_full);
226 verrou.wait(cond_empty);
235 verrou.broadcast(cond_empty);
236 verrou.broadcast(cond_full);