public class UT2004SyncLockableWorldView extends UT2004WorldView implements ILockableVisionWorldView
Contains GameBots2004 correct locking of the worldview.
All messages are processed always in batches (all messages between EndMessages are one batch) meaning that the world view is always correct!
When worldview is lock()ed it postpones the events until unlock()ed, which is triggering raising all events that came from the lock().
lock() method here blocks until the END message of the batch is hit, then the world view is considered to be fully locked and let the lock() continue. You may use it to create correct sync bot. (just lock() the world view before your logic and unlock() the world view after the logic finishes)
The world view is unlocked from the beginning.
The locking mechanism starts to work with the first BeginMessage. (To let all other events to be processed automatically during the handshake.)
, Jimmy
UT2004LockableWorldView
Modifier and Type | Field and Description |
---|---|
static String |
WORLDVIEW_DEPENDENCY |
notifyEventsList, receiveEventProcessing
COMPONENT_ID, control, controller, eventBus, log
Constructor and Description |
---|
UT2004SyncLockableWorldView(ComponentDependencies dependencies,
IMediator mediator,
IComponentBus bus,
IAgentLogger log) |
Modifier and Type | Method and Description |
---|---|
boolean |
isInLock() |
boolean |
isLocked() |
void |
lock()
When the world view is locked - no batches are processes until unlocked.
|
void |
notify(IWorldChangeEvent event)
Implements locking logic.
|
protected void |
prePause() |
protected void |
preStop() |
protected void |
resume() |
protected void |
start(boolean startPaused) |
protected void |
stop() |
void |
unlock()
Unlocks the world view - triggers processing of all events till the last
EndMessage that came between lock() / unlock() calls.
|
isBatchBeginEvent, isBatchEndEvent, setDisappearedFlag
batchAwareWorldViewNotify, hasObjectsToProcess, notifyImmediately, objectAppeared, objectDisappeared
addVisibleObject, cleanUp, getAllVisible, getAllVisible, getVisible, getVisible, objectCreated, objectDestroyed, objectUpdatedEvent, removeVisibleObject
innerNotify, notifyAfterPropagation, objectUpdated, raiseEvent
addEventListener, addObjectListener, addObjectListener, addObjectListener, addObjectListener, addWorldObject, get, get, get, getAll, getAll, getComponentId, getEventBus, getLog, getSingle, isListening, isListening, isListening, isListening, isListening, isListening, isPaused, isRunning, kill, pause, removeEventListener, removeListener, removeObjectListener, removeObjectListener, removeObjectListener, removeObjectListener, removeWorldObject, reset, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAllVisible, getAllVisible, getVisible, getVisible
addEventListener, addObjectListener, addObjectListener, addObjectListener, addObjectListener, get, get, get, getAll, getAll, getEventBus, getSingle, isListening, isListening, isListening, isListening, isListening, isListening, removeEventListener, removeListener, removeObjectListener, removeObjectListener, removeObjectListener, removeObjectListener
notifyAfterPropagation, notifyImmediately
getComponentId
public static final String WORLDVIEW_DEPENDENCY
@Inject public UT2004SyncLockableWorldView(ComponentDependencies dependencies, IMediator mediator, IComponentBus bus, IAgentLogger log)
public void lock() throws cz.cuni.amis.utils.exception.PogamutInterruptedException, ComponentNotRunningException
lock
in interface ILockableWorldView
cz.cuni.amis.utils.exception.PogamutInterruptedException
ComponentNotRunningException
public void unlock() throws ComponentNotRunningException
unlock
in interface ILockableWorldView
ComponentNotRunningException
public boolean isLocked()
isLocked
in interface ILockableWorldView
public boolean isInLock()
public void notify(IWorldChangeEvent event)
notify
in interface IWorldChangeEventInput
notify
in class BatchAwareWorldView
protected void start(boolean startPaused)
start
in class AbstractWorldView
protected void preStop()
preStop
in class AbstractWorldView
protected void prePause()
prePause
in class AbstractWorldView
protected void resume()
resume
in class AbstractWorldView
protected void stop()
stop
in class AbstractWorldView
Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.