Skip to content

feat: coordination recipes example #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

wieceslaw
Copy link

No description provided.

switch (state) {
case RECONNECTED: {
logger.debug("Session RECONNECTED");
reconnect();
Copy link
Member

Choose a reason for hiding this comment

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

Вот тут несовсем верно. Делать reconnect или нет зависит от того удалось ли сохранить сессию при потере связи или нет. Если сессия осталась (у нее не изменился идентификатор) - то все локи остались за нами, то ничего реконнектить не надо

} else {
timeout = Duration.between(Instant.now(), deadline); // TODO: use external Clock instead of Instant?
}
CompletableFuture<Result<SemaphoreLease>> acquireTask = connectedSession().acquireEphemeralSemaphore(
Copy link
Member

Choose a reason for hiding this comment

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

Наверное нужно уметь работать не только с эфемерным семафором?

lockInternals.start();
// TODO: Share same lockInternals?
this.readLock = new InternalLock(lockInternals, false);
this.writeLock = new InternalLock(lockInternals, true);
Copy link
Member

Choose a reason for hiding this comment

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

Кажется что такая схема не сработает. ReadWriteLock подразумевает что ты можешь сначала взять read лок, потом сделать upgrade до write лока. А если у тебя внутри это два разных лока - это не сработает

Copy link
Author

@wieceslaw wieceslaw Apr 9, 2025

Choose a reason for hiding this comment

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

А тут как раз лок один, просто две обертки - одна запрашивает эксклюзивный лок, а другая - неэксклюзивный

Copy link
Member

Choose a reason for hiding this comment

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

Да, я почему то думал что стандратный ReentrantReadWriteLock позволяет апгрейд с read до write. Сейчас перечитал документацию - нет, такая операция не разрешена. Возможен только дайнгрейд с write до read.

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.

2 participants