bulldog2011 / bigqueue

A big, fast and persistent queue based on memory mapped file.
http://bulldog2011.github.com/bigqueue
Apache License 2.0
558 stars 219 forks source link

Adding support for non-blocking wait #7

Closed TobiasMende closed 10 years ago

TobiasMende commented 10 years ago

It would be nice to have a possibility to use something like Java Future to wait for new items in the queue. By making use of the ListenableFuture interested objects could be informed whenever new items are enqueued.

I'd like to implement this feature as pull request if it's appreciated.

bulldog2011 commented 10 years ago

Good idea, please go ahead, do remember to add solid test cases.

Thx! -William ----- 原始邮件 ----- 发件人:Tobias Mende notifications@github.com 收件人:bulldog2011/bigqueue bigqueue@noreply.github.com 主题:[bigqueue] Adding support for non-blocking wait (#7) 日期:2014年04月01日 22点43分

TobiasMende commented 10 years ago

Here is some additional information about my pull request:

I added a method queueReadyForDequeue returning a ListenableFuture from the Guava Library. I've used the SettableFuture and the queue simply sets itself to complete the future.

I also added a couple of test ensuring that the listener's runnables are executed if new objects where enqueued.

Please let me know what you think.

Thx