Hoist semaphore ownership out of TokenExecutor#609
Open
chall37 wants to merge 1 commit into
Open
Conversation
Move creation and wait-site of the backpressure semaphore from TokenExecutor into its two callers: TaskNotifier (PTY read path) and PTYSession (channel/mux path). TokenExecutor no longer owns any semaphore; it receives one via the semaphore: parameter and passes it through to TokenArray, which signals it on consumption exactly as before. TaskNotifier creates a per-task semaphore on registration and looks it up (under tasksLock) before each read. PTYSession creates one per channel session. No semantic change intended.
Contributor
Author
|
Looks like d518a59 broke the libsixel submodule ref (from e2c8546 to d300081). Don't see the d300081 commit in libsixel fork or upstream. Maybe local changes? |
gnachman
requested changes
Mar 12, 2026
|
|
||
| // Per-task backpressure semaphores, keyed by task identity. | ||
| // Created on register, removed on deregister. | ||
| NSMapTable<id<iTermTask>, dispatch_semaphore_t> *_backpressureSemaphores; |
Owner
There was a problem hiding this comment.
What if PTYTask owned its semaphore? Then we wouldn't need _backpressureSemaphores: in fact, TaskNotifier could remain unchanged. -[PTYTask processRead] could wait on and signal its semaphore. Another benefit of doing the wait inside processRead is that it could read before waiting, reducing latency (probably very slightly) when it is eventually unblocked.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move creation and wait-site of the backpressure semaphore from TokenExecutor into its callers: TaskNotifier (PTY read path) and PTYSession (channel/mux path).
TokenExecutor no longer owns any semaphore; it receives one via the semaphore: parameter and passes it through to TokenArray, which signals it on consumption exactly as before.
TaskNotifier creates a per-task semaphore on registration and looks it up (under tasksLock) before each read. PTYSession creates one per channel session. No semantic change intended.
As a reminder, this is the first step in flow control abstraction -- no behavioral changes are intended. Next step would be the flow control interface.