resources.VidigiPriorityStore
resources.VidigiPriorityStore(self,
env,=None,
num_resources=float('inf'),
capacity )
An optimized SimPy priority store that eliminates delays between resource release and acquisition by directly triggering waiting events.
This implementation provides the same API as the original VidigiPriorityStore but with immediate resource handoff between processes.
AI USE DISCLOSURE: This code was generated by Claude 3.7 Sonnet. It has been evaluated and tested by a human.
Methods
Name | Description |
---|---|
cancel_get | Cancels a pending get request by removing it from the queue. |
get | Create an event to get an item from the store. |
get_direct | Get an item from the store without the context manager. |
populate | Populate this VidigiPriorityStore with VidigiResource objects. |
put | Put an item into the store. |
request | Request context manager for getting an item from the store. |
request_direct | Alias for get_direct() to maintain consistent API. |
return_item | Return an item to the store and immediately process any waiting get requests. |
cancel_get
resources.VidigiPriorityStore.cancel_get(get_event)
Cancels a pending get request by removing it from the queue.
get
=0) resources.VidigiPriorityStore.get(priority
Create an event to get an item from the store.
Args: priority: Lower values indicate higher priority (default: 0)
Returns: A get event that can be yielded
get_direct
=0) resources.VidigiPriorityStore.get_direct(priority
Get an item from the store without the context manager. Use this if you don’t want to automatically return the item.
Returns: A get event that can be yielded
populate
resources.VidigiPriorityStore.populate(num_resources)
Populate this VidigiPriorityStore with VidigiResource objects.
Creates num_resources
VidigiResource objects and adds them to this store.
Each VidigiResource is initialized with a capacity of 1 and a unique ID starting at 1.
Parameters
Name | Type | Description | Default |
---|---|---|---|
num_resources | int | The number of VidigiResource objects to create and add to the store. | required |
Returns
Name | Type | Description |
---|---|---|
None |
put
resources.VidigiPriorityStore.put(item)
Put an item into the store.
Args: item: The item to put in the store
Returns: A put event that can be yielded
request
=0) resources.VidigiPriorityStore.request(priority
Request context manager for getting an item from the store. The item is automatically returned when exiting the context.
Args: priority: Lower values indicate higher priority (default: 0)
Returns: A context manager that yields the get event and handles item return
request_direct
=0) resources.VidigiPriorityStore.request_direct(priority
Alias for get_direct() to maintain consistent API.
Returns: A get event that can be yielded
return_item
resources.VidigiPriorityStore.return_item(item)
Return an item to the store and immediately process any waiting get requests.
This is the key to eliminating delays - it directly triggers waiting get requests without going through the normal put/get mechanism.
Args: item: The item to return to the store