|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.webSvr.ads.AdUtils.AdSlotMonitor
public static final class AdUtils.AdSlotMonitor
Unique thread-safe marker tag and stats object for a particular ad slot. Typically a private static final in the JSP/servlet, call 'mon.done()' in the same thread as showAds(..., mon) when an ad gated/enabled by showAds() with this as arg is completed.
Used to avoid showing ads when server-side insertion is taking too long.
This is lock-free and thread-safe for multiple JSP/servlet threads to use the same slots at the same time.
| Field Summary | |
|---|---|
private java.util.concurrent.atomic.AtomicInteger |
genTimeSmoothedMs
Smoothed time of recent ad slot generation time; never null, value non-negative. |
private java.lang.ThreadLocal<java.lang.Long> |
lastStartTime
Per-thread record of last start() time for this ad slot; never null. |
java.lang.String |
name
Name of this ad slot; never null nor empty. |
private boolean |
pending
Set when any ad is start()ed, cleared when any ad is done(). |
private java.util.concurrent.atomic.AtomicInteger |
startCount
Count of ads shown in this slot (or at least for which start() was called). |
| Constructor Summary | |
|---|---|
AdUtils.AdSlotMonitor(java.lang.String name)
Construct an instance with a non-empty, non=null name. |
|
| Method Summary | |
|---|---|
void |
done()
Used by JSP code after generating text for an ad that showAds() allowed. |
int |
getGenTimeSmoothedMs()
Get current 'smoothed' recent ad generation time; non-negative. |
boolean |
mayBePending()
True if another showing of this slot may be pending. |
(package private) void |
start(SimpleLoggerIF log)
Used by showAds() to start timing an ad that it has allowed. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final java.lang.String name
private volatile boolean pending
If there is currently no ad showing and all recent ads have completed fine then this will be false.
This is kept true for as short a time as possible.
We may choose not to show ads in some cases where one may be pending, though this is not any sort of guarantee because of concurrency/exceptions.
Marked volatile for timely sharing between threads.
private final java.lang.ThreadLocal<java.lang.Long> lastStartTime
private final java.util.concurrent.atomic.AtomicInteger startCount
private final java.util.concurrent.atomic.AtomicInteger genTimeSmoothedMs
| Constructor Detail |
|---|
public AdUtils.AdSlotMonitor(java.lang.String name)
| Method Detail |
|---|
void start(SimpleLoggerIF log)
Calling start() again with no intervening done() may have no effect and/or may provoke a warning.
public void done()
Calling this if start() was not called (since the last done()) may have no effect and/or may provoke a warning.
public boolean mayBePending()
public int getGenTimeSmoothedMs()
|
DHD Multimedia Gallery V1.53.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||