rcf.core.concurrent.events
Class ArrayEventSyndicate

java.lang.Object
  extended by rcf.core.util.filter.AbstractFilter<T>
      extended by rcf.core.util.collection.AbstractImmutableCollection<T,I,SI,SC,C>
          extended by rcf.core.util.collection.AbstractCollection<T,I,SI,SV,V>
              extended by rcf.core.util.collection.vector.AbstractVector<T,rcf.core.util.collection.vector.AbstractVector.VectorIterator<T,rcf.core.util.collection.vector.ArrayVector<T>>,rcf.core.util.collection.vector.ArrayVector.SubArrayVectorIterator<T>,rcf.core.util.collection.vector.ArrayVector.SubArrayVector<T>,rcf.core.util.collection.vector.ArrayVector<T>>
                  extended by rcf.core.util.collection.vector.ArrayVector<Reference<EventSink<? super Event>>>
                      extended by rcf.core.concurrent.events.ArrayEventSyndicate
All Implemented Interfaces:
EventSink<Event>, EventSource, EventSyndicate, Transactional<rcf.core.util.collection.transaction.CollectionTransaction<Reference<EventSink<? super Event>>>>, rcf.core.util.accessor.Accessing<Reference<EventSink<? super Event>>>, rcf.core.util.adapter.TypeAdapter<Reference<EventSink<? super Event>>,Integer>, rcf.core.util.adapter.TypeAdapterA<Reference<EventSink<? super Event>>,Integer>, rcf.core.util.adapter.TypeAdapterB<Reference<EventSink<? super Event>>,Integer>, rcf.core.util.collection.Collection<Reference<EventSink<? super Event>>>, rcf.core.util.collection.ImmutableCollection<Reference<EventSink<? super Event>>>, rcf.core.util.collection.iterator.FixedUniIterable<Reference<EventSink<? super Event>>>, rcf.core.util.collection.iterator.ImmutableFixedUniIterable<Reference<EventSink<? super Event>>>, rcf.core.util.collection.ModCount, rcf.core.util.collection.vector.ImmutableVector<Reference<EventSink<? super Event>>>, rcf.core.util.collection.vector.Vector<Reference<EventSink<? super Event>>>, rcf.core.util.Copyable, rcf.core.util.filter.DynamicFilter<Reference<EventSink<? super Event>>,rcf.core.util.collection.transaction.CollectionTransaction<Reference<EventSink<? super Event>>>>, rcf.core.util.filter.Filter<Reference<EventSink<? super Event>>>, rcf.core.util.Immutable, ImmutableIterable<Reference<EventSink<? super Event>>>, Iterable<Reference<EventSink<? super Event>>>, rcf.core.util.map.mixins.ImmutableMapCollection<Reference<EventSink<? super Event>>,Integer,Reference<EventSink<? super Event>>>, rcf.core.util.map.mixins.MapCollection<Reference<EventSink<? super Event>>,Integer,Reference<EventSink<? super Event>>>

@Revision(value="$Revision: 1.10 $",
          date="$Date: 2006/12/15 20:37:48 $",
          tag="$Name:  $")
public class ArrayEventSyndicate
extends rcf.core.util.collection.vector.ArrayVector<Reference<EventSink<? super Event>>>
implements EventSyndicate

TODO: Javadoc A very simple implementation of EventSyndicate which will only report events of a single type. This is useful in situations where an event syndicate is needed only for a short period of time, for example for reporting rcf.concurrent.schedule.TaskEvent.

TODO: Unit tests, Code review, Javadoc review, Seal/Finalize TODO: equals, hashCode, toString

Version:
$Revision: 1.10 $
Author:
Greg Gibeling

Nested Class Summary
 
Nested classes/interfaces inherited from class rcf.core.util.collection.vector.ArrayVector
rcf.core.util.collection.vector.ArrayVector.Array, rcf.core.util.collection.vector.ArrayVector.SubArrayVector<T>, rcf.core.util.collection.vector.ArrayVector.SubArrayVectorIterator<T>
 
Nested classes/interfaces inherited from class rcf.core.util.collection.vector.AbstractVector
rcf.core.util.collection.vector.AbstractVector.SubVector<T,I extends rcf.core.util.collection.vector.AbstractVector.VectorIterator<T,V>,SI extends rcf.core.util.collection.vector.AbstractVector.SubVectorIterator<T,I,SI,SV,V>,SV extends rcf.core.util.collection.vector.AbstractVector.SubVector<T,I,SI,SV,V>,V extends rcf.core.util.collection.vector.AbstractVector<T,I,SI,SV,V>>, rcf.core.util.collection.vector.AbstractVector.SubVectorIterator<T,I extends rcf.core.util.collection.vector.AbstractVector.VectorIterator<T,V>,SI extends rcf.core.util.collection.vector.AbstractVector.SubVectorIterator<T,I,SI,SV,V>,SV extends rcf.core.util.collection.vector.AbstractVector.SubVector<T,I,SI,SV,V>,V extends rcf.core.util.collection.vector.AbstractVector<T,I,SI,SV,V>>, rcf.core.util.collection.vector.AbstractVector.VectorIterator<T,V extends rcf.core.util.collection.vector.Vector<T>>
 
Nested classes/interfaces inherited from class rcf.core.util.collection.AbstractCollection
rcf.core.util.collection.AbstractCollection.AbstractSubCollection<T,I extends rcf.core.util.collection.iterator.FixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractCollection.AbstractSubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractCollection.AbstractSubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractCollection<T,I,SI,SC,C>>, rcf.core.util.collection.AbstractCollection.AbstractSubCollectionIterator<T,I extends rcf.core.util.collection.iterator.FixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractCollection.AbstractSubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractCollection.AbstractSubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractCollection<T,I,SI,SC,C>>, rcf.core.util.collection.AbstractCollection.SubCollection<T,I extends rcf.core.util.collection.iterator.FixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractCollection.SubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractCollection.SubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractCollection<T,I,SI,SC,C>>, rcf.core.util.collection.AbstractCollection.SubCollectionIterator<T,I extends rcf.core.util.collection.iterator.FixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractCollection.SubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractCollection.SubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractCollection<T,I,SI,SC,C>>
 
Nested classes/interfaces inherited from class rcf.core.util.collection.AbstractImmutableCollection
rcf.core.util.collection.AbstractImmutableCollection.AbstractImmutableSubCollection<T,I extends rcf.core.util.collection.iterator.ImmutableFixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractImmutableCollection.AbstractImmutableSubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractImmutableCollection.AbstractImmutableSubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractImmutableCollection<T,I,SI,SC,C>>, rcf.core.util.collection.AbstractImmutableCollection.AbstractImmutableSubCollectionIterator<T,I extends rcf.core.util.collection.iterator.ImmutableFixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractImmutableCollection.AbstractImmutableSubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractImmutableCollection.AbstractImmutableSubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractImmutableCollection<T,I,SI,SC,C>>, rcf.core.util.collection.AbstractImmutableCollection.ImmutableSubCollection<T,I extends rcf.core.util.collection.iterator.ImmutableFixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractImmutableCollection.ImmutableSubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractImmutableCollection.ImmutableSubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractImmutableCollection<T,I,SI,SC,C>>, rcf.core.util.collection.AbstractImmutableCollection.ImmutableSubCollectionIterator<T,I extends rcf.core.util.collection.iterator.ImmutableFixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractImmutableCollection.ImmutableSubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractImmutableCollection.ImmutableSubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractImmutableCollection<T,I,SI,SC,C>>
 
Nested classes/interfaces inherited from interface rcf.core.util.filter.Filter
rcf.core.util.filter.Filter.Type
 
Nested classes/interfaces inherited from interface rcf.core.util.filter.Filter
rcf.core.util.filter.Filter.Type
 
Nested classes/interfaces inherited from interface rcf.core.util.filter.Filter
rcf.core.util.filter.Filter.Type
 
Field Summary
protected static SoftReference<rcf.core.util.accessor.Accessor<? super Reference<EventSink>>> accessor
          TODO: Javadoc
protected  Event current
          TODO: Javadoc The current event, used to reduce the possibility for infinite loops of events which include multiple syndicates.
protected  Class eventType
          TODO: Javadoc
 
Fields inherited from class rcf.core.util.collection.vector.ArrayVector
array, elements, max, offset, size
 
Fields inherited from class rcf.core.util.collection.vector.AbstractVector
adapterInverse
 
Fields inherited from class rcf.core.util.collection.AbstractCollection
collectionEventTypes, currTrans, factory, prevTrans, sequenceNumber, syndicate
 
Fields inherited from class rcf.core.util.collection.AbstractImmutableCollection
filter, hashCodeCache
 
Fields inherited from class rcf.core.util.filter.AbstractFilter
filterInverse
 
Constructor Summary
ArrayEventSyndicate(Class _eventType, rcf.core.util.filter.Filter<Reference<EventSink<? super Event>>> _filter)
          TODO: Javadoc
ArrayEventSyndicate(Class _eventType, rcf.core.util.filter.Filter<Reference<EventSink<? super Event>>> _filter, boolean _copy, Reference<EventSink<? super Event>>... _a)
          TODO: Javadoc
ArrayEventSyndicate(Class _eventType, rcf.core.util.filter.Filter<Reference<EventSink<? super Event>>> _filter, rcf.core.util.collection.ImmutableCollection<Reference<EventSink<? super Event>>> _c, boolean reversed)
          TODO: Javadoc
ArrayEventSyndicate(Class _eventType, rcf.core.util.filter.Filter<Reference<EventSink<? super Event>>> _filter, int _initialCapacity)
          TODO: Javadoc
ArrayEventSyndicate(Class _eventType, rcf.core.util.filter.Filter<Reference<EventSink<? super Event>>> _filter, int _initialCapacity, int _max)
          TODO: Javadoc
ArrayEventSyndicate(Class _eventType, Reference<EventSink<? super Event>>... _a)
          TODO: Javadoc
 
Method Summary
<E extends Event>
rcf.core.util.collection.iterator.FixedUniIterator<Reference<EventSink<? super E>>>
add(Reference<EventSink<? super E>> _sinkReference, Class<E> _class)
          Register an event sink to receive all of the events from the EventSource for this syndicate, which are assignable to the specified class.
protected static rcf.core.util.accessor.Accessor<? super Reference<EventSink<? super Event>>> cachedAccessor()
          TODO: Javadoc
 ArrayEventSyndicate copy()
           
 boolean event(Event event)
          Called by an EventSyndicate to notify this sink that an event has occured.
<E extends Event>
rcf.core.util.collection.iterator.FixedUniIterator<Reference<EventSink<? super E>>>
remove(Reference<EventSink<? super E>> _sinkReference, Class<E> _class)
          Deregister an event sink to stop receiving events from the EventSource for this syndicate.
 
Methods inherited from class rcf.core.util.collection.vector.ArrayVector
addRankAll, addRankElement, capacity, capacity, clear, createIterator, createSubVector, fill, first, firstRankOf, last, lastRankOf, moveRank, rankElement, removeRankElement, resize, setRankElement, size, sort, swapRank, toArray
 
Methods inherited from class rcf.core.util.collection.vector.AbstractVector
add, add, addAll, asAbstract, createSubCollection, equals, first, hashCode, mapA, mapB, ordering, post, pre, project, put, remove, subVector, typeAdapterInverse
 
Methods inherited from class rcf.core.util.collection.AbstractCollection
archivableTransaction, collectionEventTypes, commitTransaction, complement, complementAll, createCompositeTransaction, createdSyndicate, destroyedSyndicate, events, factory, filterInverse, getSequenceNumber, getStructuralModCount, getValueModCount, incSequenceNumber, incStructuralModCount, incValueModCount, isImmutable, isSyndicated, newTransaction, prepTransaction, remove, syndicate, transaction, transaction
 
Methods inherited from class rcf.core.util.collection.AbstractImmutableCollection
accessor, count, filter, filter, filterType, isCompatible, isEmpty, isNative, isUnique, toString
 
Methods inherited from class rcf.core.util.filter.AbstractFilter
filterAll, filterAny
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface rcf.core.concurrent.events.EventSyndicate
isEmpty, size
 
Methods inherited from interface rcf.core.util.collection.Collection
complement, complementAll, factory, remove
 
Methods inherited from interface rcf.core.util.collection.ImmutableCollection
count, filter, filter, filterAll, filterAny, isUnique
 
Methods inherited from interface rcf.core.util.iterator.ImmutableIterable
isCompatible, isEmpty, isNative
 
Methods inherited from interface rcf.core.util.filter.Filter
filterType
 
Methods inherited from interface rcf.core.util.accessor.Accessing
accessor
 
Methods inherited from interface rcf.core.util.Immutable
isImmutable
 
Methods inherited from interface rcf.core.util.collection.ModCount
getStructuralModCount, getValueModCount, incStructuralModCount, incValueModCount
 
Methods inherited from interface rcf.core.util.iterator.ImmutableIterable
isCompatible, isEmpty, isNative
 
Methods inherited from interface rcf.core.util.iterator.ImmutableIterable
isCompatible, isEmpty, isNative
 
Methods inherited from interface rcf.core.util.filter.DynamicFilter
filterInverse
 
Methods inherited from interface rcf.core.util.filter.Filter
filterType
 
Methods inherited from interface rcf.core.concurrent.transactions.Transactional
transaction, transaction
 
Methods inherited from interface rcf.core.concurrent.events.EventSource
events, getSequenceNumber, incSequenceNumber, isSyndicated, syndicate
 
Methods inherited from interface rcf.core.util.Immutable
isImmutable
 
Methods inherited from interface rcf.core.util.collection.ImmutableCollection
count, filter, filter, filterAll, filterAny, isUnique
 
Methods inherited from interface rcf.core.util.iterator.ImmutableIterable
isCompatible, isEmpty, isNative
 
Methods inherited from interface rcf.core.util.filter.Filter
filterType
 
Methods inherited from interface rcf.core.util.accessor.Accessing
accessor
 
Methods inherited from interface rcf.core.util.Immutable
isImmutable
 

Field Detail

current

protected Event current
TODO: Javadoc The current event, used to reduce the possibility for infinite loops of events which include multiple syndicates. Single syndicate loops (where this syndicate would send events to itself, will cause an exception in event(Event).

When this field is not null, no event is being reported. Before actually reporting an event the syndicate should check that it is not == current in which case an exception should be thrown. When an event is done being reported, this field should be set back to null, but only if it is == to the event which has just finished being reported. This check will ensure correctness under multi-threading, but it does decrease the utility of these checks, meaning that they are for debugging only, and cannot be relied upon to catch all cases of infinite event loops.

Note that access to this field must be synchronized on this syndicate.


eventType

protected final Class eventType
TODO: Javadoc


accessor

protected static SoftReference<rcf.core.util.accessor.Accessor<? super Reference<EventSink>>> accessor
TODO: Javadoc

Constructor Detail

ArrayEventSyndicate

public ArrayEventSyndicate(Class _eventType,
                           rcf.core.util.filter.Filter<Reference<EventSink<? super Event>>> _filter)
TODO: Javadoc

Parameters:
_filter -

ArrayEventSyndicate

public ArrayEventSyndicate(Class _eventType,
                           rcf.core.util.filter.Filter<Reference<EventSink<? super Event>>> _filter,
                           boolean _copy,
                           Reference<EventSink<? super Event>>... _a)
TODO: Javadoc

Parameters:
_filter -
_copy -
_a -

ArrayEventSyndicate

public ArrayEventSyndicate(Class _eventType,
                           rcf.core.util.filter.Filter<Reference<EventSink<? super Event>>> _filter,
                           rcf.core.util.collection.ImmutableCollection<Reference<EventSink<? super Event>>> _c,
                           boolean reversed)
TODO: Javadoc

Parameters:
_filter -
_c -
reversed -

ArrayEventSyndicate

public ArrayEventSyndicate(Class _eventType,
                           rcf.core.util.filter.Filter<Reference<EventSink<? super Event>>> _filter,
                           int _initialCapacity)
TODO: Javadoc

Parameters:
_filter -
_initialCapacity -

ArrayEventSyndicate

public ArrayEventSyndicate(Class _eventType,
                           rcf.core.util.filter.Filter<Reference<EventSink<? super Event>>> _filter,
                           int _initialCapacity,
                           int _max)
TODO: Javadoc

Parameters:
_filter -
_initialCapacity -
_max -

ArrayEventSyndicate

public ArrayEventSyndicate(Class _eventType,
                           Reference<EventSink<? super Event>>... _a)
TODO: Javadoc

Parameters:
_a -
Method Detail

cachedAccessor

protected static final rcf.core.util.accessor.Accessor<? super Reference<EventSink<? super Event>>> cachedAccessor()
TODO: Javadoc

Returns:

copy

public ArrayEventSyndicate copy()
Specified by:
copy in interface rcf.core.util.collection.Collection<Reference<EventSink<? super Event>>>
Specified by:
copy in interface rcf.core.util.collection.ImmutableCollection<Reference<EventSink<? super Event>>>
Specified by:
copy in interface rcf.core.util.collection.vector.ImmutableVector<Reference<EventSink<? super Event>>>
Specified by:
copy in interface rcf.core.util.collection.vector.Vector<Reference<EventSink<? super Event>>>
Specified by:
copy in interface rcf.core.util.Copyable
Specified by:
copy in interface rcf.core.util.filter.DynamicFilter<Reference<EventSink<? super Event>>,rcf.core.util.collection.transaction.CollectionTransaction<Reference<EventSink<? super Event>>>>
Overrides:
copy in class rcf.core.util.collection.vector.ArrayVector<Reference<EventSink<? super Event>>>

add

public <E extends Event> rcf.core.util.collection.iterator.FixedUniIterator<Reference<EventSink<? super E>>> add(Reference<EventSink<? super E>> _sinkReference,
                                                                                                                 Class<E> _class)
Description copied from interface: EventSyndicate
Register an event sink to receive all of the events from the EventSource for this syndicate, which are assignable to the specified class.

Specified by:
add in interface EventSyndicate
Parameters:
_sinkReference - A reference to the event sink, which this syndicate is supposed to call EventSink.event(Event) on. Notice that this is a reference, so that WeakReferences can be used to avoid having this syndicate send events to an event sink which would otherwise have been garbage collected.
_class - The class of events the EventSink specified by _sinkReference wants to receive from this syndicate.
Returns:
An iterator which can be used to remove this sink from the syndicate. This return type is also chosen to be compatible with Collection and MapCollection.

remove

public <E extends Event> rcf.core.util.collection.iterator.FixedUniIterator<Reference<EventSink<? super E>>> remove(Reference<EventSink<? super E>> _sinkReference,
                                                                                                                    Class<E> _class)
Description copied from interface: EventSyndicate
Deregister an event sink to stop receiving events from the EventSource for this syndicate.

Specified by:
remove in interface EventSyndicate
Parameters:
_sinkReference - A reference to the event sink, which this syndicate should no longer report events to. Note that the Reference.type() of the reference is immaterial.
_class - The class of events the EventSink specified by _sinkReference was to receiving from this syndicate.
Returns:
An iterator which can be used to remove this sink from the syndicate. This return type is also chosen to be compatible with Collection and MapCollection.

event

public boolean event(Event event)
Description copied from interface: EventSink
Called by an EventSyndicate to notify this sink that an event has occured.

Specified by:
event in interface EventSink<Event>
Specified by:
event in interface EventSyndicate
Parameters:
event - The event which has occured.
Returns:
true to keep receiving events from the source of this event. false to stop receiving events from the source of this event.
See Also:
EventSink.event(rcf.core.concurrent.events.Event)