Reworked client impl of interest

We should reschedule the task if there is nothing to process. That could be
done within the task itself at a regular interval (possibly with
exponential back off), or rescheduling could be done when we insert the
task into the queue, and there is no task already scheduled. The latter
would be more complex  to implement (race conditions) but more efficient.

On Mon, Sep 15, 2014 at 11:08 PM, qiangdavidliu <notifications@github.com>
wrote:

> In
> eureka-client/src/main/java/com/netflix/eureka/client/InterestProcessor.java:
>
> > +            @Override
> > +            public void call() {
> > +                Task<Interest<InstanceInfo>> task = taskQueue.poll();
> > +                if (task != null) {
> > +                    Interest<InstanceInfo> interest = task.getInput();
> > +                    if (interestStream != null) {
> > +                        interestChannel.upgrade(interest).subscribe(task);
> > +                    } else {
> > +                        interestStream = interestChannel.register(interest);
> > +                    }
> > +
> > +                    // subscribe the tasks to the (singleton) channel stream to propagate onError and onComplete
> > +                    interestStream.ignoreElements().cast(Void.class).subscribe(task);
> > +                }
> > +
> > +                taskProcessor.schedule(this);  // repeat
>
> It is. Most of the time the work should be a queue.poll() and a task !=
> null check. How optimized is the computation scheduler in rx? If a tight
> loop is expensive we can add a delay for each iteration.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/Netflix/eureka/pull/201/files#r17584836>.
>