* @brief Get an entity from this queue. * * This function won't be blocked. * * @param item Reference of an entity to hold the got data. * * @return If got data, return true. Otherwise, return false. */
| 222 | * @return If got data, return true. Otherwise, return false. |
| 223 | */ |
| 224 | bool Get(T& item) { |
| 225 | bool ret = false; |
| 226 | lock_.lock(); |
| 227 | if (!queue_.empty()) { |
| 228 | ret = true; |
| 229 | item = std::move(queue_.front()); |
| 230 | queue_.pop_front(); |
| 231 | } |
| 232 | lock_.unlock(); |
| 233 | return ret; |
| 234 | } |
| 235 | |
| 236 | void Clear() { |
| 237 | lock_.lock(); |