Skip to content

feat: run scheduled tasks across threads in parallel - #17

Merged
AaronCQL merged 1 commit into
mainfrom
feat/parallel-scheduler
Apr 25, 2026
Merged

feat: run scheduled tasks across threads in parallel#17
AaronCQL merged 1 commit into
mainfrom
feat/parallel-scheduler

Conversation

@AaronCQL

Copy link
Copy Markdown
Owner

Summary

  • Scheduler now launches each due task in its own goroutine (with sync.WaitGroup), so tasks targeting different threads run concurrently
  • Same-thread serialisation still enforced by the existing chatState mutex in runQueuedTask
  • Adds outboxMu to prevent concurrent goroutines from reading and sending duplicate outbox entries

Test plan

  • go build ./... passes
  • go test ./... passes
  • Verify two cron jobs at the same time across different threads run in parallel
  • Verify two cron jobs in the same thread still serialise correctly

Previously, all due tasks executed sequentially in the scheduler loop,
meaning one slow task in thread A would block an unrelated task in
thread B. Now each due task runs in its own goroutine, with a WaitGroup
preventing re-pickup on the next tick. Same-thread serialisation is
still enforced by the existing chatState mutex.

Adds outboxMu to guard the outbox read+remove cycle against concurrent
goroutines sending duplicate file entries.
@AaronCQL
AaronCQL merged commit c439895 into main Apr 25, 2026
1 check passed
@AaronCQL
AaronCQL deleted the feat/parallel-scheduler branch April 25, 2026 02:01
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.

1 participant