yahoo / imapnio

Java imap nio client that is designed to scale well for thousands of connections per machine and reduce contention when using large number of threads and cpus.
57 stars 50 forks source link

ISSUE-86 Allow passing callbacks to ImapFuture #118

Closed chibenwa closed 2 years ago

chibenwa commented 2 years ago

This allow avoiding blocking in calling code to unwrap the future and access the inner value. This empowers reactive/asynchronous/actor systems integrations.

I chose the callback approach instead of using CompletableFuture in order to minimize code changes.

Description

Adds callbacks to ImapFuture

Motivation and Context

Needs to call ImapFuture.get to do anything usefull with this library however it blocks and defeat any reactive/asynchronous/actor system use of this library.

How Has This Been Tested?

Unit test. I will also ensure timely that this solves my original issue.

Screenshots (if appropriate):

Types of changes

Checklist:

Javadoc.

chibenwa commented 2 years ago

Hi,

I will take a look in the coming days.

I will be able to make those changes solely in ImapFuture by allowing registrations solely on this object.

When a callback is registered, we modify ImapFuture inner structured then immediately run it if the future is done. This makes it fully transparent from the existing interfaces and allows its use for the full asynchronous API, not just for the exec method.

Would this be an evolution of this work that would be welcomed?

Regards,

Benoit

chibenwa commented 2 years ago

Hello,

Any input on this topic dear imapnio maintainers?

Best regards,

Benoit TELLIER

chibenwa commented 2 years ago

Cool!

As a side question, when to expect a 4.3.8 so that I can drop my fork?

Best regards,

Benoit

fansu commented 2 years ago

@chibenwa We just upgrade to 4.3.8, artifacts will be published within a day.