YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.share.ProviderCallGate Class Reference

Lets at most ONE call per content provider be in flight, so that one hostile or hanging provider can never occupy more than one thread of the shared pool, however often it is asked. More...

Collaboration diagram for de.yaacc.share.ProviderCallGate:
Collaboration graph

Classes

class  Permit
 Proof of one admitted call; hand it back to release when the call returned.
 

Public Member Functions

 ProviderCallGate (int maxTracked)
 
synchronized Permit tryAcquire (String key)
 
synchronized void release (Permit permit)
 The call returned (result, failure, refusal by the pool or never started).
 

Static Public Member Functions

static ProviderCallGate createDefault ()
 The production gate with the number of ShareLimits.
 

Detailed Description

Lets at most ONE call per content provider be in flight, so that one hostile or hanging provider can never occupy more than one thread of the shared pool, however often it is asked.

Plain Java.

A permit lives exactly as long as its call: tryAcquire refuses a provider whose earlier call has not returned (it may be running, or hung in a Binder call that cannot be interrupted, with the caller long gone), and release, which the pooled task runs in a finally the moment the call returns, frees it. There is deliberately NO expiry: a thread that is still pinned must stay accounted for, or the same provider could pin one more thread per interval until the whole pool is gone. The gate also refuses everybody when maxTracked providers already have a call outstanding, so the map is bounded by that number whatever keys arrive, and so are the pool threads inside provider calls.

Residual: a call that never returns keeps its thread and its place until the process ends; maxTracked such providers (distinct packages) use up all places.

The key is whatever identifies the provider: the package that owns the authority where it can be resolved (one app with many authorities is one provider), else one fixed key shared by every provider that cannot be resolved.

Constructor & Destructor Documentation

◆ ProviderCallGate()

de.yaacc.share.ProviderCallGate.ProviderCallGate ( int maxTracked)
Parameters
maxTrackedproviders with a call outstanding at once, at least 1

Referenced by de.yaacc.share.ProviderCallGate.createDefault().

Here is the caller graph for this function:

Member Function Documentation

◆ release()

synchronized void de.yaacc.share.ProviderCallGate.release ( Permit permit)

The call returned (result, failure, refusal by the pool or never started).

Safe to call more than once.

◆ tryAcquire()

synchronized Permit de.yaacc.share.ProviderCallGate.tryAcquire ( String key)
Returns
a permit, or null if this provider has a call outstanding or the gate is full

The documentation for this class was generated from the following file: