|
YAACC - UPNP Client and Server
|
Caps the number of responses that are streaming from one share at the same time. More...

Classes | |
| class | Lease |
One running response; release() is idempotent. | |
| enum | State |
Public Member Functions | |
| ShareConcurrencyLimiter (int max) | |
| ShareConcurrencyLimiter (int max, LongSupplier clock) | |
| Lease | tryAcquire (String key) |
| int | expireIdle (long idleMillis) |
Takes the slot away from every lease that made no progress for more than idleMillis. | |
| int | activeCount (String key) |
| int | trackedKeys () |
Static Public Member Functions | |
| static ShareConcurrencyLimiter | shared () |
| The limiter of the whole process (the HTTP server's responses and the sweeper share it). | |
Caps the number of responses that are streaming from one share at the same time.
A response takes a Lease before it starts and gives it back when it ends; the lease can be released any number of times (the HTTP library may report the end of a response through more than one callback). Plain Java, thread safe.
Watchdog: a response reports its progress to the lease (Lease#noteProgress); a periodic expireIdle takes the slot away from a lease that made no progress for the idle time, so a stalled or trickling reader cannot hold the slots of a share. The response itself is not cut off: if it is called again (the reader resumed after a pause) it asks for a slot again (Lease#tryReacquire(), same cap) and aborts only if the share is full. The slot is given back exactly once, however often a lease expired and resumed.
| de.yaacc.share.ShareConcurrencyLimiter.ShareConcurrencyLimiter | ( | int | max | ) |
| IllegalArgumentException | if max is not positive |
| de.yaacc.share.ShareConcurrencyLimiter.ShareConcurrencyLimiter | ( | int | max, |
| LongSupplier | clock ) |
| clock | monotonic milliseconds |
| IllegalArgumentException | if max is not positive |
| int de.yaacc.share.ShareConcurrencyLimiter.activeCount | ( | String | key | ) |
| int de.yaacc.share.ShareConcurrencyLimiter.expireIdle | ( | long | idleMillis | ) |
Takes the slot away from every lease that made no progress for more than idleMillis.
Call it periodically (the share sweeper does, every minute).
| IllegalArgumentException | if idleMillis is not positive |
| int de.yaacc.share.ShareConcurrencyLimiter.trackedKeys | ( | ) |
| Lease de.yaacc.share.ShareConcurrencyLimiter.tryAcquire | ( | String | key | ) |
| key | a well-formed share key (ShareRegistry#isWellFormedKey) |
