Skip to content

Support passing Async::Semaphore as the parent task for Async::Job::Processor::Redis::Server - #5

Open
shaokun wants to merge 1 commit into
socketry:mainfrom
shaokun:features/async-semaphore-as-parent
Open

Support passing Async::Semaphore as the parent task for Async::Job::Processor::Redis::Server#5
shaokun wants to merge 1 commit into
socketry:mainfrom
shaokun:features/async-semaphore-as-parent

Conversation

@shaokun

@shaokun shaokun commented Dec 8, 2025

Copy link
Copy Markdown

Summary

This PR refactors the Async::Job::Processor::Redis::Server to support passing an Async::Semaphore as the parent task. The change restructures the concurrency model by moving job processing into a separate async task wrapper, allowing for better control over concurrent job execution through semaphores.

Key Changes:

  • Refactored task hierarchy: The main server loop now runs in a separate async task, with each job dequeue operation wrapped in its own transient task with the semaphore/parent as its parent
  • Simplified dequeue method: Removed the parent parameter from dequeue - job processing logic is now synchronous within its async wrapper
  • Better concurrency control: Enables limiting concurrent job processing by passing a semaphore with a specific limit

This change maintains backward compatibility while enabling use cases where you want to limit the number of jobs processed concurrently (e.g., rate limiting, resource management).

Types of Changes

  • New feature.
  • Maintenance.

Contribution

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