Several Resources
A task can hold more than one resource at once; this page shows how, and an example in which two resources compete.
How to Use It
A task can hold several resources at once: resource: [picker, bench] asks for a picker, then, while it holds the picker, for the bench. The task is served once it holds all of them, and it releases all of them when it finishes. While it waits for the bench it holds the picker: the holding is partial, and nothing is granted to several resources at once. patience covers the whole acquisition, and an interrupt gives back every unit held.
A task can also hand a unit to the next task of its flow with keep: the next task holds it from the start and gives it back once it publishes started, so an order keeps the picker until it is on the packing bench. The competing-resources example does both:
In the low-level API several resources are nested requests, and a handoff is a request released by the next process.
One order of acquisition. Two tasks that acquire the same two resources in opposite orders can each hold one and wait for ever for the other. desflow refuses such a model when it is built, naming both tasks: every task, keep handoffs and request branches of a wait included, must acquire shared resources in one order (Wait for a Unit, an Item or Room). Competing Resources shows what a partial holding costs.
Example: Competing Resources
The competing-resources example: orders keep the picker until they are on the bench, and gifts hold the picker and the bench together. It needs no Docker service and ends on its own after 120 simulation seconds.
Quick Start
desflow examples get downloads the example at the release you install, into a folder of its own. Pick uv or pip:
The whole file is examples/yaml/competing_resources.yaml.
Quick Start
desflow examples get downloads the example at the release you install, into a folder of its own. Pick uv or pip:
The whole file is examples/builder/competing_resources_example.py.
Quick Start
desflow examples get downloads the example at the release you install, into a folder of its own. Pick uv or pip:
The whole file is examples/low-level/competing_resources_example.py.