Some type safety, redundant cast removal, and other code hygiene.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4879 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -97,8 +97,7 @@ public class OccupantDirector extends BasicDirector
|
|||||||
public OccupantInfo getOccupantInfo (int bodyOid)
|
public OccupantInfo getOccupantInfo (int bodyOid)
|
||||||
{
|
{
|
||||||
// make sure we're somewhere
|
// make sure we're somewhere
|
||||||
return (_place == null) ? null :
|
return (_place == null) ? null : _place.occupantInfo.get(Integer.valueOf(bodyOid));
|
||||||
(OccupantInfo)_place.occupantInfo.get(Integer.valueOf(bodyOid));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -416,7 +416,7 @@ public class Streamer
|
|||||||
/**
|
/**
|
||||||
* Constructs a streamer for the specified target class.
|
* Constructs a streamer for the specified target class.
|
||||||
*/
|
*/
|
||||||
protected Streamer (Class target)
|
protected Streamer (Class<?> target)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
// keep a handle on the class
|
// keep a handle on the class
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public class InvocationDirector
|
|||||||
|
|
||||||
// if we're logged on, clear out any receiver id mapping
|
// if we're logged on, clear out any receiver id mapping
|
||||||
if (_clobj != null) {
|
if (_clobj != null) {
|
||||||
Registration rreg = (Registration)_clobj.receivers.get(receiverCode);
|
Registration rreg = _clobj.receivers.get(receiverCode);
|
||||||
if (rreg == null) {
|
if (rreg == null) {
|
||||||
Log.warning("Receiver unregistered for which we have no id to code mapping " +
|
Log.warning("Receiver unregistered for which we have no id to code mapping " +
|
||||||
"[code=" + receiverCode + "].");
|
"[code=" + receiverCode + "].");
|
||||||
|
|||||||
@@ -34,31 +34,28 @@ import com.threerings.presents.dobj.InvocationNotificationEvent;
|
|||||||
public abstract class InvocationSender
|
public abstract class InvocationSender
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Requests that the specified invocation notification be packaged up
|
* Requests that the specified invocation notification be packaged up and sent to the supplied
|
||||||
* and sent to the supplied target client.
|
* target client.
|
||||||
*/
|
*/
|
||||||
public static void sendNotification (
|
public static void sendNotification (
|
||||||
ClientObject target, String receiverCode, int methodId, Object[] args)
|
ClientObject target, String receiverCode, int methodId, Object[] args)
|
||||||
{
|
{
|
||||||
// convert the receiver hash id into the code used on this
|
// convert the receiver hash id into the code used on this
|
||||||
// specific client
|
// specific client
|
||||||
Registration rreg = (Registration)target.receivers.get(receiverCode);
|
Registration rreg = target.receivers.get(receiverCode);
|
||||||
if (rreg == null) {
|
if (rreg == null) {
|
||||||
Log.warning("Unable to locate receiver for invocation " +
|
Log.warning("Unable to locate receiver for invocation service notification " +
|
||||||
"service notification [clobj=" + target.who() +
|
"[clobj=" + target.who() + ", code=" + receiverCode +
|
||||||
", code=" + receiverCode + ", methId=" + methodId +
|
", methId=" + methodId + ", args=" + StringUtil.toString(args) + "].");
|
||||||
", args=" + StringUtil.toString(args) + "].");
|
|
||||||
Thread.dumpStack();
|
Thread.dumpStack();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Log.info("Sending notification [target=" + target +
|
// Log.info("Sending notification [target=" + target + ", code=" + receiverCode +
|
||||||
// ", code=" + receiverCode + ", methodId=" + methodId +
|
// ", methodId=" + methodId + ", args=" + StringUtil.toString(args) + "].");
|
||||||
// ", args=" + StringUtil.toString(args) + "].");
|
|
||||||
|
|
||||||
// create and dispatch an invocation notification event
|
// create and dispatch an invocation notification event
|
||||||
target.postEvent(
|
target.postEvent(
|
||||||
new InvocationNotificationEvent(
|
new InvocationNotificationEvent(target.getOid(), rreg.receiverId, methodId, args));
|
||||||
target.getOid(), rreg.receiverId, methodId, args));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import sun.misc.Perf;
|
|
||||||
|
|
||||||
import com.samskivert.util.AuditLogger;
|
import com.samskivert.util.AuditLogger;
|
||||||
import com.samskivert.util.HashIntMap;
|
import com.samskivert.util.HashIntMap;
|
||||||
import com.samskivert.util.Histogram;
|
import com.samskivert.util.Histogram;
|
||||||
@@ -297,8 +295,7 @@ public class PresentsDObjectMgr
|
|||||||
*/
|
*/
|
||||||
protected void processUnit (Object unit)
|
protected void processUnit (Object unit)
|
||||||
{
|
{
|
||||||
long start = _timer.highResCounter();
|
long start = System.nanoTime();
|
||||||
long freq = _timer.highResFrequency();
|
|
||||||
|
|
||||||
// keep track of the largest queue size we've seen
|
// keep track of the largest queue size we've seen
|
||||||
int queueSize = _evqueue.size();
|
int queueSize = _evqueue.size();
|
||||||
@@ -339,8 +336,7 @@ public class PresentsDObjectMgr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// compute the elapsed time in microseconds
|
// compute the elapsed time in microseconds
|
||||||
long elapsed = _timer.highResCounter() - start;
|
long elapsed = (System.nanoTime() - start)/1000;
|
||||||
elapsed = elapsed * 1000000 / freq;
|
|
||||||
|
|
||||||
// report excessively long units
|
// report excessively long units
|
||||||
if (elapsed > 500000 && !(unit instanceof LongRunnable)) {
|
if (elapsed > 500000 && !(unit instanceof LongRunnable)) {
|
||||||
@@ -859,17 +855,16 @@ public class PresentsDObjectMgr
|
|||||||
protected static void registerEventHelpers ()
|
protected static void registerEventHelpers ()
|
||||||
{
|
{
|
||||||
Class[] ptypes = new Class[] { DEvent.class, DObject.class };
|
Class[] ptypes = new Class[] { DEvent.class, DObject.class };
|
||||||
Class omgrcl = PresentsDObjectMgr.class;
|
|
||||||
Method method;
|
Method method;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
method = omgrcl.getMethod("objectDestroyed", ptypes);
|
method = PresentsDObjectMgr.class.getMethod("objectDestroyed", ptypes);
|
||||||
_helpers.put(ObjectDestroyedEvent.class, method);
|
_helpers.put(ObjectDestroyedEvent.class, method);
|
||||||
|
|
||||||
method = omgrcl.getMethod("objectAdded", ptypes);
|
method = PresentsDObjectMgr.class.getMethod("objectAdded", ptypes);
|
||||||
_helpers.put(ObjectAddedEvent.class, method);
|
_helpers.put(ObjectAddedEvent.class, method);
|
||||||
|
|
||||||
method = omgrcl.getMethod("objectRemoved", ptypes);
|
method = PresentsDObjectMgr.class.getMethod("objectRemoved", ptypes);
|
||||||
_helpers.put(ObjectRemovedEvent.class, method);
|
_helpers.put(ObjectRemovedEvent.class, method);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -981,9 +976,6 @@ public class PresentsDObjectMgr
|
|||||||
* thread. */
|
* thread. */
|
||||||
protected Thread _dobjThread;
|
protected Thread _dobjThread;
|
||||||
|
|
||||||
/** Used during unit profiling for timing values. */
|
|
||||||
protected Perf _timer = Perf.getPerf();
|
|
||||||
|
|
||||||
/** A monotonically increasing counter used to assign an id to all dispatched events. */
|
/** A monotonically increasing counter used to assign an id to all dispatched events. */
|
||||||
protected long _nextEventId = 1;
|
protected long _nextEventId = 1;
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class PresentsInvoker extends Invoker
|
|||||||
|
|
||||||
if (PresentsDObjectMgr.UNIT_PROF_ENABLED) {
|
if (PresentsDObjectMgr.UNIT_PROF_ENABLED) {
|
||||||
for (Object key : _tracker.keySet()) {
|
for (Object key : _tracker.keySet()) {
|
||||||
UnitProfile profile = (UnitProfile)_tracker.get(key);
|
UnitProfile profile = _tracker.get(key);
|
||||||
if (key instanceof Class) {
|
if (key instanceof Class) {
|
||||||
key = StringUtil.shortClassName((Class)key);
|
key = StringUtil.shortClassName((Class)key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class ClassUtil
|
|||||||
{
|
{
|
||||||
Class tclass = target.getClass();
|
Class tclass = target.getClass();
|
||||||
String key = tclass.getName() + ":" + name;
|
String key = tclass.getName() + ":" + name;
|
||||||
Method method = (Method)cache.get(key);
|
Method method = cache.get(key);
|
||||||
|
|
||||||
if (method == null) {
|
if (method == null) {
|
||||||
method = findMethod(tclass, name);
|
method = findMethod(tclass, name);
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class StreamableHashMap<K,V> extends HashMap<K,V>
|
|||||||
int ecount = size();
|
int ecount = size();
|
||||||
out.writeInt(ecount);
|
out.writeInt(ecount);
|
||||||
for (Iterator<Map.Entry<K,V>> iter = entrySet().iterator(); iter.hasNext(); ) {
|
for (Iterator<Map.Entry<K,V>> iter = entrySet().iterator(); iter.hasNext(); ) {
|
||||||
Map.Entry<K,V> entry = (Map.Entry<K,V>) iter.next();
|
Map.Entry<K,V> entry = iter.next();
|
||||||
out.writeObject(entry.getKey());
|
out.writeObject(entry.getKey());
|
||||||
out.writeObject(entry.getValue());
|
out.writeObject(entry.getValue());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class TrackedObject
|
|||||||
{
|
{
|
||||||
Class clazz = getClass();
|
Class clazz = getClass();
|
||||||
synchronized (_map) {
|
synchronized (_map) {
|
||||||
int[] count = (int[])_map.get(clazz);
|
int[] count = _map.get(clazz);
|
||||||
if (count == null) {
|
if (count == null) {
|
||||||
_map.put(clazz, count = new int[1]);
|
_map.put(clazz, count = new int[1]);
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ public class TrackedObject
|
|||||||
{
|
{
|
||||||
Class clazz = getClass();
|
Class clazz = getClass();
|
||||||
synchronized (_map) {
|
synchronized (_map) {
|
||||||
int[] count = (int[])_map.get(clazz);
|
int[] count = _map.get(clazz);
|
||||||
if (count != null) {
|
if (count != null) {
|
||||||
count[0]--;
|
count[0]--;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user