Skip to content

Conversation

@XRater
Copy link
Owner

@XRater XRater commented Mar 7, 2018

No description provided.

@Override
public <U> LightFuture<U> thenApply(@NotNull final Function<T, ? extends U> f) {
final Supplier<U> supplier = () -> f.apply(Task.this.get());
return addTask(supplier);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" Метод thenApply не должен блокировать работу потока, если результат задачи X ещё не вычислен", -1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно добавить тест, который это проверяет

if (!isWorking) {
throw new ThreadPoolIsTurnedDownException();
}
if (supplier == POISON_PILL) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вся эта машинерия с POISON_PILL -- это по сути хак, от которого код ни в одном месте не становится понятней. -0.5

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Предлагаю просто сделать булевый флаг

@XRater
Copy link
Owner Author

XRater commented Apr 30, 2018 via email

@XRater
Copy link
Owner Author

XRater commented Apr 30, 2018 via email

@dzharkov
Copy link

  1. Про poison pill на ваше усмотрение тогда
  2. "Надо, чтобы thenApply порождала задачу, которая просто
    ставится в очередь пула и работает как обычные задачи." кажется, что неправильно блокировать потоки заведомо заблокированной задачей

@XRater
Copy link
Owner Author

XRater commented Apr 30, 2018 via email

@dzharkov
Copy link

Там же простая идея: храним в родительской таске список дочерних и кладем их в общую очередь после окончания родительской

@XRater
Copy link
Owner Author

XRater commented Apr 30, 2018 via email

@XRater
Copy link
Owner Author

XRater commented Apr 30, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants