| 32 | namespace tensorflow { |
| 33 | |
| 34 | class FIFOQueue : public TypedQueue<std::deque<PersistentTensor> > { |
| 35 | public: |
| 36 | FIFOQueue(int32 capacity, const DataTypeVector& component_dtypes, |
| 37 | const std::vector<TensorShape>& component_shapes, |
| 38 | const string& name); |
| 39 | |
| 40 | // Implementations of QueueInterface methods -------------------------------- |
| 41 | |
| 42 | void TryEnqueue(const Tuple& tuple, OpKernelContext* ctx, |
| 43 | DoneCallback callback) override; |
| 44 | void TryEnqueueMany(const Tuple& tuple, OpKernelContext* ctx, |
| 45 | DoneCallback callback) override; |
| 46 | void TryDequeue(OpKernelContext* ctx, CallbackWithTuple callback) override; |
| 47 | void TryDequeueMany(int num_elements, OpKernelContext* ctx, |
| 48 | bool allow_small_batch, |
| 49 | CallbackWithTuple callback) override; |
| 50 | Status MatchesNodeDef(const NodeDef& node_def) override; |
| 51 | |
| 52 | int32 size() const override { |
| 53 | mutex_lock lock(mu_); |
| 54 | return queues_[0].size(); |
| 55 | } |
| 56 | |
| 57 | protected: |
| 58 | ~FIFOQueue() override {} |
| 59 | |
| 60 | // Helper for dequeuing a single element from queues_. |
| 61 | void DequeueLocked(OpKernelContext* ctx, Tuple* tuple) |
| 62 | EXCLUSIVE_LOCKS_REQUIRED(mu_); |
| 63 | |
| 64 | static Status GetElementComponentFromBatch(const Tuple& tuple, int64 index, |
| 65 | int component, |
| 66 | OpKernelContext* ctx, |
| 67 | PersistentTensor* out_element); |
| 68 | |
| 69 | private: |
| 70 | TF_DISALLOW_COPY_AND_ASSIGN(FIFOQueue); |
| 71 | }; |
| 72 | |
| 73 | // Defines a FIFOQueueOp, which produces a Queue (specifically, one |
| 74 | // backed by FIFOQueue) that persists across different graph |
no outgoing calls