tomp2p / TomP2P

A P2P-based high performance key-value pair storage library
http://tomp2p.net
Apache License 2.0
438 stars 122 forks source link

Refactor tomp2p futures to use java.util.concurrent.Future #127

Closed lyze closed 8 years ago

lyze commented 8 years ago

TomP2P should use java.util.concurrent.Future.

Consider a class such as net.tomp2p.dht.FutureGet. A refactoring with java.util.concurrent.Future would have it implement Future<DhtResult>, where DhtResult would be a new interface that contains the data-related methods, like rawData(), dataMap(), etc.

tbocek commented 8 years ago

The current futures in TomP2P are based on MINA/Netty and I modified them according to my needs. That means, I did not spend a lot of time improving them and they work quite well.

One key feature, I'm missing in the java Future implementation is the possibility for adding a listener. A better alternative are those ListenableFuture (https://github.com/google/guava/wiki/ListenableFutureExplained, or https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/util/concurrent/ListenableFuture.html). However, I don't want to add the guava libarary as a dependency for just this feature. I look quickly for a standalone implemenation, but they did not convince me.

If you want to contribute this, feel free to do so.

tbocek commented 8 years ago

The current futures in TomP2P are based on MINA/Netty and I modified them according to my needs. That means, I did not spend a lot of time improving them and they work quite well.

One key feature, I'm missing in the java Future implementation is the possibility for adding a listener. A better alternative are those ListenableFuture (https://github.com/google/guava/wiki/ListenableFutureExplained, or https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/util/concurrent/ListenableFuture.html). However, I don't want to add the guava libarary as a dependency for just this feature. I look quickly for a standalone implemenation, but they did not convince me.

If you want to contribute this, feel free to do so.

lyze commented 8 years ago

I believe that refactoring to ListenableFuture from Guava will help to eliminate problems with listeners being run on the wrong thread.

If you approve of potentially contributing this change, I will bring in the guava library as a dependency.