| 32 | } |
| 33 | |
| 34 | Status FunctionHandleCache::Instantiate( |
| 35 | const string& function_name, AttrSlice attrs, |
| 36 | FunctionLibraryRuntime::InstantiateOptions options, |
| 37 | FunctionLibraryRuntime::Handle* handle) { |
| 38 | string key = Canonicalize(function_name, attrs, options); |
| 39 | FunctionLibraryRuntime::Handle h; |
| 40 | { |
| 41 | tf_shared_lock l(mu_); |
| 42 | h = gtl::FindWithDefault(handles_, key, kInvalidHandle); |
| 43 | } |
| 44 | if (h == kInvalidHandle) { |
| 45 | options.state_handle = state_handle_; |
| 46 | TF_RETURN_IF_ERROR( |
| 47 | lib_->Instantiate(function_name, attrs, options, handle)); |
| 48 | mutex_lock l(mu_); |
| 49 | handles_[key] = *handle; |
| 50 | } else { |
| 51 | *handle = h; |
| 52 | } |
| 53 | return Status::OK(); |
| 54 | } |
| 55 | |
| 56 | Status FunctionHandleCache::Clear() { |
| 57 | mutex_lock l(mu_); |
nothing calls this directly
no test coverage detected