CMObject
, CMLibrary
, ThreadEngine
, java.lang.Cloneable
, java.lang.Comparable<CMObject>
, java.lang.Runnable
public class ServiceEngine extends java.lang.Object implements ThreadEngine
Modifier and Type | Field | Description |
---|---|---|
protected java.util.List<TickableGroup> |
allTicks |
|
static long |
STATUS_ALLMISCTICKS |
idConverter
Constructor | Description |
---|---|
ServiceEngine() |
Modifier and Type | Method | Description |
---|---|---|
boolean |
activate() |
Activates the library.
|
protected void |
addTickGroup(TickableGroup tock) |
|
void |
checkHealth() |
|
void |
clearDebri(Room room,
TickableGroup.LocalType typeCode) |
Deletes the ticks of all the objects in the
room of the given type.
|
int |
compareTo(CMObject o) |
|
CMObject |
copyOf() |
Similar to Cloneable.clone(), but does its best to make sure that
any internal objects to this class are also copyOfed.
|
protected static void |
debugDumpThreadGroup(java.lang.ThreadGroup tGroup,
java.lang.StringBuilder lines) |
|
boolean |
deleteTick(Tickable E,
int tickID) |
Searches the TickGroups for the given Tickable, on the
given tickID, and deletes it.
|
protected void |
delTickGroup(TickableGroup tock) |
|
void |
dumpDebugStack(java.lang.String ID,
java.lang.Thread theThread) |
Dumps a stack trace, logging with the given ID
|
void |
executeRunnable(char threadGroupId,
java.lang.Runnable R) |
Execute a runnable in an available thread, right now,
or as soon as humanly possible.
|
void |
executeRunnable(java.lang.Runnable R) |
Execute a runnable in an available thread, right now,
or as soon as humanly possible.
|
void |
executeRunnable(java.lang.String threadGroupName,
java.lang.Runnable R) |
Execute a runnable in an available thread, right now,
or as soon as humanly possible.
|
java.lang.Runnable |
findRunnableByThread(java.lang.Thread thread) |
This is used for determining the runner on the given thread,
which involves scanning thread pools for some reason?
|
java.util.List<TickClient> |
findTickClient(java.lang.String name,
boolean exactOnly) |
Finds all the TickClients with tickers matching
the given name.
|
protected java.lang.ThreadGroup |
getAreaThemeThreadGroup(Tickable E) |
|
int |
getMaxObjectsPerThread() |
|
java.util.List<Tickable> |
getNamedTickingObjects(java.lang.String name) |
Does an In-String search of all ticking objects
and returns them.
|
protected CMThreadPoolExecutor |
getPoolExecutor(char threadGroupNum) |
|
protected CMThreadPoolExecutor |
getPoolExecutor(java.lang.String threadGroupName) |
|
TickClient |
getServiceClient() |
If this library has a service thread, this method returns the TickClient
object associated with that service.
|
java.lang.String |
getSystemReport(java.lang.String itemCode) |
Retreives special thread related information about
map objects.
|
long |
getTickGroupPeriod(Tickable E,
int tickID) |
Searches the TickGroups for the given Tickable, and returns
the number of milliseconds that its tick group is using as
a "tick".
|
java.lang.String |
getTickInfoReport(java.lang.String which) |
Retreives special internal information from
the thread engine of the callers thread
group, mostly for the web server.
|
protected long |
getTicksEllapsedSinceStartup() |
|
java.lang.String |
getTickStatusSummary(Tickable obj) |
A bit out of date, this returns the status of the
given ticking object as a descriptive string.
|
long |
getTimeMsToNextTick(Tickable E,
int tickID) |
Searches the TickGroups for the given Tickable, and returns
the number of miliseconds (roughly) before it will tick
again.
|
java.lang.String |
ID() |
The CoffeeMud Java Class ID shared by all instances of
this object.
|
void |
initializeClass() |
Called ONCE after all objects are loaded, but before the map is read in
during initialization.
|
void |
insertOrderDeathInOrder(DVector DV,
long lastStart,
java.lang.String msg,
TickableGroup tock) |
|
boolean |
isAllSuspended() |
Returns whether all threads are currently in
the global suspended thread.
|
boolean |
isSuspended(Tickable E,
int tickID) |
Returns whether the given Tickable is currently
suspended from receiving tick time, despite being
assigned a tick group.
|
boolean |
isTicking(Tickable E,
int tickID) |
Searches the TickGroups for the given Tickable, returning true
if it was found still registered to a Tick Client.
|
java.lang.String |
L(java.lang.String str,
java.lang.String... xs) |
Localize an internal string -- shortcut.
|
java.lang.String |
name() |
The displayable name of this object.
|
CMObject |
newInstance() |
Returns a new instance of this class.
|
static void |
panicDumpAllThreads() |
|
void |
propertiesLoaded() |
This method is called whenever system properties are altered by the user.
|
void |
rejuv(Room here,
int tickID) |
Given a map room, this will find all the rejuvable items and
mobs associated with the room and force them to respawn.
|
void |
resumeAll() |
Resumes all thread ticking, assuming they were
all previously suspended.
|
void |
resumeTicking(Tickable E,
int tickID) |
Resumes the thread time for this tick,
if it was previously suspended.
|
void |
run() |
|
void |
scheduleRunnable(java.lang.Runnable R,
long ellapsedMs) |
Schedule a runnable to be executed in the future.
|
void |
setSupportStatus(java.lang.String s) |
|
boolean |
setTickPending(Tickable E,
int tickID) |
If the given Tickable is waiting multiple ticks
before they get time, this will set them to
pending, meaning they will wake up on the very
next opportunity.
|
boolean |
shutdown() |
Shuts down the library.
|
TickClient |
startTickDown(Tickable E,
int tickID,
int numTicks) |
Starts a standard repeating "ticker", on standard Tick time.
|
TickClient |
startTickDown(Tickable E,
int tickID,
long tickTimeMs,
int numTicks) |
Starts a standard repeating "ticker", but with
a custom Tick time.
|
TickClient |
startTickDown(java.lang.ThreadGroup group,
Tickable E,
int tickID,
long tickTimeMs,
int numTicks) |
|
void |
suspendAll(CMRunnable[] exceptRs) |
Suspend all threads, preventing anything from
getting official tick time, except for the given
runnable, typically a Session.
|
void |
suspendResumeRecurse(CMObject O,
boolean skipEmbeddedAreas,
boolean suspend) |
Suspends or Resumes all embedded mobs, items, etc inside
the given area, room, mob, etc.
|
protected boolean |
suspendResumeTicking(Tickable E,
int tickID,
boolean suspend) |
|
void |
suspendTicking(Tickable E,
int tickID) |
Suspends any actual thread time for this tick,
without removing it from its tick group.
|
void |
tickAllTickers(Room here) |
Given a map room, this will find and force-tick every one of those
objects, on the current tick group.
|
java.util.Iterator<TickableGroup> |
tickGroups() |
Returns an iterator over all the existing tick groups.
|
boolean |
unTickAll(Tickable ticker) |
A special method that deletes all known ticks of
all tick ids from the given object, but also deletes
all ticks of any objects dependent on it, such as
item on mobs, effects on things, in rooms, etc.
|
public static final long STATUS_ALLMISCTICKS
protected java.util.List<TickableGroup> allTicks
public java.lang.String ID()
CMObject
public java.lang.String name()
CMObject
name
in interface CMObject
Environmental.Name()
public CMObject newInstance()
CMObject
newInstance
in interface CMObject
public java.lang.String L(java.lang.String str, java.lang.String... xs)
CMLibrary
L
in interface CMLibrary
str
- the string to translatexs
- the array of variables to replaceCall with the string to translate, which may contain variables of the form @x1, @x2, etc. The array in xs
is then used to replace the variables AFTER the string is translated.
public void initializeClass()
CMObject
initializeClass
in interface CMObject
public CMObject copyOf()
CMObject
public int compareTo(CMObject o)
compareTo
in interface java.lang.Comparable<CMObject>
public void propertiesLoaded()
CMLibrary
propertiesLoaded
in interface CMLibrary
public TickClient getServiceClient()
CMLibrary
getServiceClient
in interface CMLibrary
TickClient
protected CMThreadPoolExecutor getPoolExecutor(char threadGroupNum)
protected CMThreadPoolExecutor getPoolExecutor(java.lang.String threadGroupName)
public java.util.Iterator<TickableGroup> tickGroups()
ThreadEngine
tickGroups
in interface ThreadEngine
public java.lang.Runnable findRunnableByThread(java.lang.Thread thread)
ThreadEngine
findRunnableByThread
in interface ThreadEngine
thread
- the thread to get the runnable forpublic void scheduleRunnable(java.lang.Runnable R, long ellapsedMs)
ThreadEngine
scheduleRunnable
in interface ThreadEngine
R
- the runnable to executeellapsedMs
- the number of milliseconds before executingThreadEngine.scheduleRunnable(Runnable, long)
,
ThreadEngine.executeRunnable(Runnable)
,
ThreadEngine.executeRunnable(char, Runnable)
,
ThreadEngine.executeRunnable(String, Runnable)
public void executeRunnable(java.lang.String threadGroupName, java.lang.Runnable R)
ThreadEngine
executeRunnable
in interface ThreadEngine
threadGroupName
- the thread group to execute it inR
- the runnable to executeThreadEngine.scheduleRunnable(Runnable, long)
,
ThreadEngine.executeRunnable(Runnable)
,
ThreadEngine.executeRunnable(char, Runnable)
,
ThreadEngine.executeRunnable(String, Runnable)
public void executeRunnable(char threadGroupId, java.lang.Runnable R)
ThreadEngine
executeRunnable
in interface ThreadEngine
threadGroupId
- the thread group to execute it inR
- the runnable to executeThreadEngine.scheduleRunnable(Runnable, long)
,
ThreadEngine.executeRunnable(Runnable)
,
ThreadEngine.executeRunnable(char, Runnable)
,
ThreadEngine.executeRunnable(String, Runnable)
public void executeRunnable(java.lang.Runnable R)
ThreadEngine
executeRunnable
in interface ThreadEngine
R
- the runnable to executeThreadEngine.scheduleRunnable(Runnable, long)
,
ThreadEngine.executeRunnable(Runnable)
,
ThreadEngine.executeRunnable(char, Runnable)
,
ThreadEngine.executeRunnable(String, Runnable)
public int getMaxObjectsPerThread()
protected long getTicksEllapsedSinceStartup()
protected void delTickGroup(TickableGroup tock)
protected void addTickGroup(TickableGroup tock)
protected java.lang.ThreadGroup getAreaThemeThreadGroup(Tickable E)
public TickClient startTickDown(Tickable E, int tickID, int numTicks)
ThreadEngine
startTickDown
in interface ThreadEngine
E
- The Ticking objecttickID
- the tick id denoting the type of eventnumTicks
- the number of given ticks between Tickable tickspublic TickClient startTickDown(Tickable E, int tickID, long tickTimeMs, int numTicks)
ThreadEngine
startTickDown
in interface ThreadEngine
E
- The Ticking objecttickID
- the tick id denoting the type of eventtickTimeMs
- the time between ticks, usually globalnumTicks
- the number of given ticks between Tickable tickspublic long getTickGroupPeriod(Tickable E, int tickID)
ThreadEngine
getTickGroupPeriod
in interface ThreadEngine
E
- the Tickable to search fortickID
- the assigned tick id, or -1 for ANYpublic TickClient startTickDown(java.lang.ThreadGroup group, Tickable E, int tickID, long tickTimeMs, int numTicks)
public boolean deleteTick(Tickable E, int tickID)
ThreadEngine
deleteTick
in interface ThreadEngine
E
- the Tickable to search fortickID
- the assigned tick id, or -1 for ALLpublic boolean setTickPending(Tickable E, int tickID)
ThreadEngine
setTickPending
in interface ThreadEngine
E
- the Tickable to search fortickID
- the assigned tick id, or -1 for ALLpublic long getTimeMsToNextTick(Tickable E, int tickID)
ThreadEngine
getTimeMsToNextTick
in interface ThreadEngine
E
- the Tickable to search fortickID
- the assigned tick id, or -1 for ANYpublic boolean isTicking(Tickable E, int tickID)
ThreadEngine
isTicking
in interface ThreadEngine
E
- the Tickable to search fortickID
- the assigned tick id, or -1 for ANYpublic boolean isAllSuspended()
ThreadEngine
isAllSuspended
in interface ThreadEngine
ThreadEngine.resumeTicking(Tickable, int)
,
ThreadEngine.suspendTicking(Tickable, int)
,
ThreadEngine.suspendResumeRecurse(CMObject, boolean, boolean)
,
ThreadEngine.isSuspended(Tickable, int)
,
ThreadEngine.suspendAll(CMRunnable[])
,
ThreadEngine.resumeAll()
public void suspendAll(CMRunnable[] exceptRs)
ThreadEngine
suspendAll
in interface ThreadEngine
exceptRs
- null, or the runnables to NOT suspendThreadEngine.resumeTicking(Tickable, int)
,
ThreadEngine.suspendTicking(Tickable, int)
,
ThreadEngine.suspendResumeRecurse(CMObject, boolean, boolean)
,
ThreadEngine.isSuspended(Tickable, int)
,
ThreadEngine.resumeAll()
,
ThreadEngine.isAllSuspended()
public void resumeAll()
ThreadEngine
resumeAll
in interface ThreadEngine
ThreadEngine.resumeTicking(Tickable, int)
,
ThreadEngine.suspendTicking(Tickable, int)
,
ThreadEngine.suspendResumeRecurse(CMObject, boolean, boolean)
,
ThreadEngine.isSuspended(Tickable, int)
,
ThreadEngine.suspendAll(CMRunnable[])
,
ThreadEngine.isAllSuspended()
public void suspendTicking(Tickable E, int tickID)
ThreadEngine
suspendTicking
in interface ThreadEngine
E
- the Tickable to search fortickID
- the assigned tick id, or -1 for ALLThreadEngine.resumeTicking(Tickable, int)
,
ThreadEngine.suspendResumeRecurse(CMObject, boolean, boolean)
,
ThreadEngine.isSuspended(Tickable, int)
,
ThreadEngine.suspendAll(CMRunnable[])
,
ThreadEngine.resumeAll()
,
ThreadEngine.isAllSuspended()
public void resumeTicking(Tickable E, int tickID)
ThreadEngine
resumeTicking
in interface ThreadEngine
E
- the Tickable to search fortickID
- the assigned tick id, or -1 for ALLThreadEngine.suspendTicking(Tickable, int)
,
ThreadEngine.suspendResumeRecurse(CMObject, boolean, boolean)
,
ThreadEngine.isSuspended(Tickable, int)
,
ThreadEngine.suspendAll(CMRunnable[])
,
ThreadEngine.resumeAll()
,
ThreadEngine.isAllSuspended()
protected boolean suspendResumeTicking(Tickable E, int tickID, boolean suspend)
public boolean isSuspended(Tickable E, int tickID)
ThreadEngine
isSuspended
in interface ThreadEngine
E
- the Tickable to search fortickID
- the assigned tick id, or -1 for ALLThreadEngine.resumeTicking(Tickable, int)
,
ThreadEngine.suspendTicking(Tickable, int)
,
ThreadEngine.suspendResumeRecurse(CMObject, boolean, boolean)
,
ThreadEngine.suspendAll(CMRunnable[])
,
ThreadEngine.resumeAll()
,
ThreadEngine.isAllSuspended()
public java.lang.String getSystemReport(java.lang.String itemCode)
ThreadEngine
getSystemReport
in interface ThreadEngine
itemCode
- the special variable to get value ofpublic void rejuv(Room here, int tickID)
ThreadEngine
rejuv
in interface ThreadEngine
here
- the room to force rejuv items intickID
- -1 for items and mobs, or TICKID_MOB or TICKID_ROOM_ITEM_REJUVpublic java.util.List<TickClient> findTickClient(java.lang.String name, boolean exactOnly)
ThreadEngine
findTickClient
in interface ThreadEngine
name
- the string name to matchexactOnly
- true for exact only, false for partialpublic void tickAllTickers(Room here)
ThreadEngine
tickAllTickers
in interface ThreadEngine
here
- the room to tick objects inpublic void suspendResumeRecurse(CMObject O, boolean skipEmbeddedAreas, boolean suspend)
ThreadEngine
suspendResumeRecurse
in interface ThreadEngine
O
- the object to suspend ticks on and well insideskipEmbeddedAreas
- true to skip ships and the likesuspend
- true to suspend, false to resumeThreadEngine.resumeTicking(Tickable, int)
,
ThreadEngine.suspendTicking(Tickable, int)
,
ThreadEngine.isSuspended(Tickable, int)
,
ThreadEngine.suspendAll(CMRunnable[])
,
ThreadEngine.resumeAll()
,
ThreadEngine.isAllSuspended()
public boolean unTickAll(Tickable ticker)
ThreadEngine
unTickAll
in interface ThreadEngine
ticker
- the object to go completely quietpublic java.lang.String getTickInfoReport(java.lang.String which)
ThreadEngine
getTickInfoReport
in interface ThreadEngine
which
- the special encoded variable to returnpublic boolean shutdown()
CMLibrary
shutdown
in interface CMLibrary
CMLibrary.activate()
public void clearDebri(Room room, TickableGroup.LocalType typeCode)
ThreadEngine
clearDebri
in interface ThreadEngine
room
- the mob to delete objects fromtypeCode
- the type of objectsTickableGroup.LocalType
public java.util.List<Tickable> getNamedTickingObjects(java.lang.String name)
ThreadEngine
getNamedTickingObjects
in interface ThreadEngine
name
- the partial namepublic java.lang.String getTickStatusSummary(Tickable obj)
ThreadEngine
getTickStatusSummary
in interface ThreadEngine
obj
- the object that is maybe tickingpublic void insertOrderDeathInOrder(DVector DV, long lastStart, java.lang.String msg, TickableGroup tock)
public void setSupportStatus(java.lang.String s)
public void dumpDebugStack(java.lang.String ID, java.lang.Thread theThread)
ThreadEngine
dumpDebugStack
in interface ThreadEngine
ID
- the log id, a string of your choicetheThread
- the thread to dumpprotected static void debugDumpThreadGroup(java.lang.ThreadGroup tGroup, java.lang.StringBuilder lines)
public final void checkHealth()
public void run()
run
in interface java.lang.Runnable
public boolean activate()
CMLibrary
activate
in interface CMLibrary
CMLibrary.shutdown()
public static void panicDumpAllThreads()