| 91 | } |
| 92 | |
| 93 | Status IteratorResource::Save(SerializationContext* ctx, |
| 94 | IteratorStateWriter* writer) { |
| 95 | std::shared_ptr<State> captured_state; |
| 96 | { |
| 97 | tf_shared_lock l(mu_); |
| 98 | captured_state = iterator_state_; |
| 99 | } |
| 100 | if (captured_state->iterator) { |
| 101 | return captured_state->iterator->Save(ctx, writer); |
| 102 | } |
| 103 | return errors::FailedPrecondition( |
| 104 | "Save() failed because the iterator has not been initialized. Ensure " |
| 105 | "that you have run the initializer operation for this iterator before " |
| 106 | "saving it."); |
| 107 | } |
| 108 | |
| 109 | Status IteratorResource::Restore(OpKernelContext* ctx, |
| 110 | IteratorStateReader* reader) { |