Package io.a2a.server.events
Class EventQueue
java.lang.Object
io.a2a.server.events.EventQueue
- All Implemented Interfaces:
AutoCloseable
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intprotected final BlockingQueue<EventQueueItem>protected final Semaphore -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedEventQueue(int queueSize) protectedEventQueue(EventQueue parent) -
Method Summary
Modifier and TypeMethodDescriptionabstract voidabstract voidclose()abstract voidclose(boolean immediate) abstract voidclose(boolean immediate, boolean notifyParent) Close this queue with control over parent notification (ChildQueue only).dequeueEventItem(int waitMilliSeconds) Dequeues an EventQueueItem from the queue.protected voiddoClose()protected voiddoClose(boolean immediate) voidenqueueEvent(Event event) voidenqueueItem(EventQueueItem item) intbooleanisClosed()voidtaskDone()
-
Field Details
-
DEFAULT_QUEUE_SIZE
public static final int DEFAULT_QUEUE_SIZE- See Also:
-
queue
-
semaphore
-
-
Constructor Details
-
EventQueue
protected EventQueue() -
EventQueue
protected EventQueue(int queueSize) -
EventQueue
-
-
Method Details
-
getQueueSize
public int getQueueSize() -
awaitQueuePollerStart
- Throws:
InterruptedException
-
enqueueEvent
-
enqueueItem
-
dequeueEventItem
Dequeues an EventQueueItem from the queue.This method returns the full EventQueueItem wrapper, allowing callers to check metadata like whether the event is replicated via
EventQueueItem.isReplicated().- Parameters:
waitMilliSeconds- the maximum time to wait in milliseconds- Returns:
- the EventQueueItem, or null if timeout occurs
- Throws:
EventQueueClosedException- if the queue is closed and empty
-
taskDone
public void taskDone() -
close
public abstract void close()- Specified by:
closein interfaceAutoCloseable
-
close
public abstract void close(boolean immediate) -
close
public abstract void close(boolean immediate, boolean notifyParent) Close this queue with control over parent notification (ChildQueue only).- Parameters:
immediate- If true, clear all pending events immediatelynotifyParent- If true, notify parent (standard behavior). If false, close this queue without decrementing parent's reference count (used for non-blocking non-final tasks to keep MainQueue alive for resubscription)- Throws:
UnsupportedOperationException- if called on MainQueue
-
isClosed
public boolean isClosed() -
doClose
protected void doClose() -
doClose
protected void doClose(boolean immediate)
-