| 241 | } |
| 242 | |
| 243 | Status ResourceMgr::Cleanup(const string& container) { |
| 244 | { |
| 245 | tf_shared_lock l(mu_); |
| 246 | if (!gtl::FindOrNull(containers_, container)) { |
| 247 | // Nothing to cleanup. |
| 248 | return Status::OK(); |
| 249 | } |
| 250 | } |
| 251 | Container* b = nullptr; |
| 252 | { |
| 253 | mutex_lock l(mu_); |
| 254 | auto iter = containers_.find(container); |
| 255 | if (iter == containers_.end()) { |
| 256 | // Nothing to cleanup, it's OK (concurrent cleanup). |
| 257 | return Status::OK(); |
| 258 | } |
| 259 | b = iter->second; |
| 260 | containers_.erase(iter); |
| 261 | } |
| 262 | CHECK(b != nullptr); |
| 263 | delete b; |
| 264 | return Status::OK(); |
| 265 | } |
| 266 | |
| 267 | static bool IsValidContainerName(StringPiece s) { |
| 268 | using ::tensorflow::strings::Scanner; |