-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Porting SimPy resources (#51 and #50) made it pretty obvious that uSim's Resources type is a bit awkward when there really is just one type of resources.
resources = Resources(capacity=8)
await resource.increase(capacity=8)
await resource.decrease(capacity=8)
async with resource.borrow(capacity=8):
...Other ways to emulate a Semaphore are Tracked and Queue, which come with other unwanted baggage. IMO the Resources interface is good, but we may want a "just one type" version:
resources = Resource(8)
await resource.increase(8)
await resource.decrease(8)
async with resource.borrow(8):
...The use-case of a raw Semaphore would be easily handled by having proper defaults:
resources = Resource() # default level of 0
await resource.increase() # default in/decrease of 1
await resource.decrease()
async with resource.borrow(): # default borrow/claim of 1
...Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request