Implemented a Ray-proposed solution where we keep track of events that were

(pre-applied and) posted before we received our object but processed (and hence
dispatched to us) after we received our object.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4715 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2007-05-18 03:37:14 +00:00
parent db3fe80e9d
commit 9bcca099ac
10 changed files with 268 additions and 230 deletions
@@ -93,6 +93,17 @@ public class PresentsDObjectMgr
PresentsServer.registerReporter(this);
}
/**
* Returns the id to be assigned to the next event posted to the event queue.
*
* @param increment if true, the event id will be incremented so that the caller can "claim"
* the returned event id.
*/
public synchronized long getNextEventId (boolean increment)
{
return increment ? _nextEventId++ : _nextEventId;
}
/**
* Sets up an access controller that will be provided to any distributed objects created on the
* server. The controllers can subsequently be overridden if desired, but a default controller
@@ -169,7 +180,8 @@ public class PresentsDObjectMgr
// from interface DObjectManager
public void postEvent (DEvent event)
{
// just append it to the queue
// assign the event's id and append it to the queue
event.eventId = getNextEventId(true);
_evqueue.append(event);
}
@@ -973,6 +985,9 @@ public class PresentsDObjectMgr
/** 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. */
protected long _nextEventId = 1;
/** Used to profile our events and runnable units. */
protected HashMap<String,UnitProfile> _profiles = new HashMap<String,UnitProfile>();