|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.hiveevents.ChannelImpl<T>
net.sourceforge.hiveevents.SyncChannelImpl<T>
public class SyncChannelImpl<T>
Thread-safe implementation of an Event Channel.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class net.sourceforge.hiveevents.ChannelImpl |
---|
ChannelImpl.AbstractConsumerInfo<T>, ChannelImpl.ConsumerInfo<T> |
Constructor Summary | |
---|---|
SyncChannelImpl(java.lang.String name,
int pullConsumerPriority,
java.lang.Class<T> clazz,
boolean logEvents)
|
Method Summary | |
---|---|
void |
block()
Temporarily block the Channel, ie any supplied event will be stored inside the Channel but not dispatched to consumers until the Channel is unblocked. |
protected ChannelImpl.ConsumerInfo<T> |
getConsumer(int idConsumer)
|
void |
push(T event)
Called by an event supplier to trigger this Channel to notify all consumers about a new event. |
int |
registerPullConsumer(Filter<T> filter)
Registers a pull-consumer to this Channel. |
int |
registerPushConsumer(int priority,
Filter<T> filter,
Consumer<T> consumer)
Registers a push-consumer to this Channel. |
void |
unblock()
Unblocks a Channel that was blocked ie any event that was received during the blocking time is dispatched to all consumers and any new event received will be normally dispatched as well. |
void |
unregisterAllConsumers()
Unregister all consumers from this Channel. |
void |
unregisterConsumer(int idConsumer)
Unregister the identified consumer from this Channel. |
Methods inherited from class net.sourceforge.hiveevents.ChannelImpl |
---|
getName, logEvent, pull, pull, purgeConsumers, registerConsumer, registerPullConsumer, registerPushConsumer, unblockPullConsumer |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SyncChannelImpl(java.lang.String name, int pullConsumerPriority, java.lang.Class<T> clazz, boolean logEvents)
Method Detail |
---|
public void block()
Channel
If called n times, unblock()
must also be called n times to
unblock the Channel.
block
in interface Channel<T>
block
in class ChannelImpl<T>
public void unblock()
Channel
This method has no effect if the Channel is not currently blocked.
It has no effect either if it has been called less times than
block()
.
unblock
in interface Channel<T>
unblock
in class ChannelImpl<T>
public void unregisterConsumer(int idConsumer)
Channel
unregisterConsumer
in interface Channel<T>
unregisterConsumer
in class ChannelImpl<T>
idConsumer
- the unique id of the consumer to unregister. If this
id does not exist, then the method does nothing.public void unregisterAllConsumers()
Channel
unregisterAllConsumers
in interface Channel<T>
unregisterAllConsumers
in class ChannelImpl<T>
public int registerPushConsumer(int priority, Filter<T> filter, Consumer<T> consumer)
Channel
registerPushConsumer
in interface Channel<T>
registerPushConsumer
in class ChannelImpl<T>
priority
- the priority (order) with which the new consumer should
be notified of new events, the lower the sooner.filter
- a filter instance that will be called for each event
received by the Channel in order to decide whether the new consumer must
be notified of this event or notconsumer
- the actual instance that will be notified
(push()
) when events are supplied to the Channel
public int registerPullConsumer(Filter<T> filter)
Channel
pull()
on this Channel on behalf of that consumer).
registerPullConsumer
in interface Channel<T>
registerPullConsumer
in class ChannelImpl<T>
filter
- a filter instance that will be called for each event
received by the Channel in order to decide whether the new consumer must
be notified of this event or not
pull()
)public void push(T event)
Channel
push
in interface Channel<T>
push
in interface Consumer<T>
push
in class ChannelImpl<T>
event
- the event notified (can be anything)protected ChannelImpl.ConsumerInfo<T> getConsumer(int idConsumer)
getConsumer
in class ChannelImpl<T>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |