Skip to content

refactor: extract Executor struct, remove CommandSucceeded from channel#38

Merged
cecton merged 7 commits into
rustminded:mainfrom
cecton:refactor/executor
Jun 23, 2026
Merged

refactor: extract Executor struct, remove CommandSucceeded from channel#38
cecton merged 7 commits into
rustminded:mainfrom
cecton:refactor/executor

Conversation

@cecton

@cecton cecton commented Jun 22, 2026

Copy link
Copy Markdown
Member

The Event enum previously carried both watcher events (ChangeDetected)
and build-completion signals (CommandSucceeded) on the same mpsc
channel. Separate these concerns by introducing a dedicated Executor
struct that owns the build thread and reports completion through the
channel via a lightweight BuildFinished nudge.

Changes

  • Executor struct with spawn/cancel/take_result — encapsulates
    SharedChild, JoinHandle<bool>, and a wake-up callback
  • WatchEvent (formerly Event) — only ChangeDetected { git: bool }
    and BuildFinished remain; CommandSucceeded is gone
  • run() — build completion is signaled by a BuildFinished nudge on
    the channel, which wakes recv_timeout immediately. The lock is
    released by polling exec.take_result() in the BuildFinished handler.
  • No functional change, all existing tests pass

cecton added 2 commits June 22, 2026 12:59
The Event enum previously carried both watcher events (ChangeDetected)
and build-completion signals (CommandSucceeded) on the same mpsc
channel.  Extract a dedicated Executor struct that owns the build
thread and lets the main loop poll for completion via JoinHandle.
This removes the conceptual dual-role of Event and eliminates the
channel round-trip for lock-release signalling.

- Introduce Executor with spawn/cancel/take_result methods
- Rename Event to WatchEvent (only ChangeDetected remains)
- Refactor run() to poll exec.take_result() instead of receiving
  CommandSucceeded through the watcher channel
- No functional change
Only the Timeout branch poll is needed — builds that complete during
the debounce wait are caught there.  The outer-loop and inner-loop-top
polls always see None.
@cecton cecton requested a review from yozhgoor June 22, 2026 12:32
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
cecton added 4 commits June 23, 2026 09:30
- Remove generation from Executor — staleness handled by dropping
  JoinHandle on cancel().  take_result() only sees the current build.
- Add WatchEvent::BuildFinished variant sent from build thread on
  exit.  Wakes recv_timeout immediately so lock is released without
  waiting for the debounce timeout.
Executor no longer depends on mpsc.  The wake-up mechanism is
abstracted behind a plain callable.
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs
@cecton cecton merged commit f8e2e7b into rustminded:main Jun 23, 2026
6 checks passed
@cecton cecton deleted the refactor/executor branch June 23, 2026 09:33
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