rabbitmq / rabbitmq-common

Common library used by rabbitmq-server and rabbitmq-erlang-client
Other
66 stars 112 forks source link

Add `worker_pool:dispatch_sync` function #368

Closed HoloRin closed 4 years ago

HoloRin commented 4 years ago

dispatch_sync sits in between the behavior of submit and submit_async, blocking the caller until a worker begins the task (submit blocks until the task is scheduled and complete, while submit_async does not block at all).

This is useful when you want to throttle submissions to the pool from a single process, such that all workers are busy, but there exists no backlog of work for the pool.

HoloRin commented 4 years ago

There is already a worker pool suite in the server repo. These tests should be moved there or that suite should be moved to this repo but we should not keep both.

I'll move that suite here, since I think next to it's implementation is a more obvious location (I looked for the suite before creating this one, but didn't find it).

michaelklishin commented 4 years ago

The new tests depend on rabbit_ct_helpers which was not listed as a test dependency in this repo, hence the CI failures. It's been added in master.

HoloRin commented 4 years ago

Thanks @michaelklishin

gerhard commented 4 years ago

@michaelklishin I need the worker_pool_dispatch_sync branch & startup_memory_fix from https://github.com/rabbitmq/rabbitmq-server/pull/2279 for rabbitmq/tgir#8. Let's keep them around for the duration of TGIR Season 1 which runs through to 25th December 2020. Thanks!

dumbbell commented 4 years ago

Backported to 3.8.x as part of rabbitmq/rabbitmq-common#387.