square / tape

A lightning fast, transactional, file-based FIFO for Android and Java.
https://square.github.io/tape/
Apache License 2.0
2.47k stars 287 forks source link

Implement the BlockingQueue as a wrapper around the QueueFile #201

Open pschichtel opened 6 years ago

pschichtel commented 6 years ago

The resulting BlockingFileQueue is thread-safe and unbounded. Thread-safety is implemented with a single lock around all operations against the backing queue.

Closes #198

pschichtel commented 6 years ago

I switched to the ObjectQueue as the backing structure as I generally agree that it's more useful, however I'm not entirely sure what overhead this adds in case I'm really only using byte[] buffers (as I am in the project where code this originally comes from).

pschichtel commented 6 years ago

The current implementation is also unbounded and I don't intend to implement an upper bound because the backing queue also doesn't have an upper bound. If an upper bound is added to the QueueFile in the future it would be good to add one here as well.

pschichtel commented 6 years ago

I'll take a look into directly accessing QueueFile for BlockingQueue<byte[]> instance without duplicating the whole class.

pschichtel commented 6 years ago

@f2prateek So that's the state I would go with. In order to implement ObjectQueue<byte[]> on QueueFile I had to break the current API a little as file():QueueFile on ObjectQueue conflicted with file():File in QueueFile, so I moved file():QueueFile to FileObjectQueue. This way we don't have the noop file():QueueFile on InMemoryObjectQueue and QueueFile can implement ObjectQueue<byte[]> basically as-is.

pschichtel commented 6 years ago

Any updates here?

pschichtel commented 2 years ago

@NightlyNexus I guess this won't be merged?