Wip cleaning iterators

This commit is contained in:
nathan 2015-05-13 20:08:09 +02:00
parent f746615536
commit 060a00f875
3 changed files with 57 additions and 56 deletions

View File

@ -93,12 +93,12 @@ public class MultiMBassador implements IMessageBus {
try { try {
while (true) { while (true) {
IN_QUEUE.take(node); IN_QUEUE.take(node);
publish(node.item1);
switch (node.messageType) { // switch (node.messageType) {
case 1: publish(node.item1); continue; // case 1: publish(node.item1); continue;
case 2: publish(node.item1, node.item2); continue; // case 2: publish(node.item1, node.item2); continue;
case 3: publish(node.item1, node.item2, node.item3); continue; // case 3: publish(node.item1, node.item2, node.item3); continue;
} // }
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
if (!MultiMBassador.this.shuttingDown) { if (!MultiMBassador.this.shuttingDown) {
@ -189,7 +189,7 @@ public class MultiMBassador implements IMessageBus {
Subscription sub; Subscription sub;
// Run subscriptions // Run subscriptions
if (subscriptions != null && !subscriptions.isEmpty()) { if (subscriptions != null) {
current = subscriptions.head; current = subscriptions.head;
while (current != null) { while (current != null) {
sub = current.getValue(); sub = current.getValue();
@ -203,7 +203,7 @@ public class MultiMBassador implements IMessageBus {
if (!this.forceExactMatches) { if (!this.forceExactMatches) {
StrongConcurrentSetV8<Subscription> superSubscriptions = manager.getSuperSubscriptions(messageClass); StrongConcurrentSetV8<Subscription> superSubscriptions = manager.getSuperSubscriptions(messageClass);
// now get superClasses // now get superClasses
if (superSubscriptions != null && !superSubscriptions.isEmpty()) { if (superSubscriptions != null) {
current = superSubscriptions.head; current = superSubscriptions.head;
while (current != null) { while (current != null) {
sub = current.getValue(); sub = current.getValue();
@ -286,7 +286,7 @@ public class MultiMBassador implements IMessageBus {
Subscription sub; Subscription sub;
// Run subscriptions // Run subscriptions
if (subscriptions != null && !subscriptions.isEmpty()) { if (subscriptions != null) {
current = subscriptions.head; current = subscriptions.head;
while (current != null) { while (current != null) {
sub = current.getValue(); sub = current.getValue();
@ -300,7 +300,7 @@ public class MultiMBassador implements IMessageBus {
if (!this.forceExactMatches) { if (!this.forceExactMatches) {
StrongConcurrentSetV8<Subscription> superSubscriptions = manager.getSuperSubscriptions(messageClass1, messageClass2); StrongConcurrentSetV8<Subscription> superSubscriptions = manager.getSuperSubscriptions(messageClass1, messageClass2);
// now get superClasses // now get superClasses
if (superSubscriptions != null && !superSubscriptions.isEmpty()) { if (superSubscriptions != null) {
current = superSubscriptions.head; current = superSubscriptions.head;
while (current != null) { while (current != null) {
sub = current.getValue(); sub = current.getValue();
@ -407,7 +407,7 @@ public class MultiMBassador implements IMessageBus {
Subscription sub; Subscription sub;
// Run subscriptions // Run subscriptions
if (subscriptions != null && !subscriptions.isEmpty()) { if (subscriptions != null) {
current = subscriptions.head; current = subscriptions.head;
while (current != null) { while (current != null) {
sub = current.getValue(); sub = current.getValue();
@ -422,7 +422,7 @@ public class MultiMBassador implements IMessageBus {
if (!this.forceExactMatches) { if (!this.forceExactMatches) {
StrongConcurrentSetV8<Subscription> superSubscriptions = manager.getSuperSubscriptions(messageClass1, messageClass2, messageClass3); StrongConcurrentSetV8<Subscription> superSubscriptions = manager.getSuperSubscriptions(messageClass1, messageClass2, messageClass3);
// now get superClasses // now get superClasses
if (superSubscriptions != null && !superSubscriptions.isEmpty()) { if (superSubscriptions != null) {
current = superSubscriptions.head; current = superSubscriptions.head;
while (current != null) { while (current != null) {
sub = current.getValue(); sub = current.getValue();

View File

@ -401,7 +401,7 @@ public class SubscriptionManager {
Subscription sub; Subscription sub;
StrongConcurrentSetV8<Subscription> subs = local2.get(arrayVersion); StrongConcurrentSetV8<Subscription> subs = local2.get(arrayVersion);
if (subs != null && !subs.isEmpty()) { if (subs != null) {
current = subs.head; current = subs.head;
while (current != null) { while (current != null) {
sub = current.getValue(); sub = current.getValue();
@ -436,7 +436,7 @@ public class SubscriptionManager {
StrongConcurrentSetV8<Class<?>> types = getSuperClasses(arrayVersion); StrongConcurrentSetV8<Class<?>> types = getSuperClasses(arrayVersion);
if (types.isEmpty()) { if (types.isEmpty()) {
local.put(varArgType, EMPTY_SUBS); local.put(varArgType, EMPTY_SUBS);
return null; return EMPTY_SUBS;
} }
Map<Class<?>, StrongConcurrentSetV8<Subscription>> local2 = this.subscriptionsPerMessageSingle; Map<Class<?>, StrongConcurrentSetV8<Subscription>> local2 = this.subscriptionsPerMessageSingle;
@ -447,14 +447,14 @@ public class SubscriptionManager {
ISetEntry<Class<?>> current1; ISetEntry<Class<?>> current1;
Class<?> superClass; Class<?> superClass;
current1 = types.head;
current1 = types.head;
while (current1 != null) { while (current1 != null) {
superClass = current1.getValue(); superClass = current1.getValue();
current1 = current1.next(); current1 = current1.next();
StrongConcurrentSetV8<Subscription> subs = local2.get(superClass); StrongConcurrentSetV8<Subscription> subs = local2.get(superClass);
if (subs != null && !subs.isEmpty()) { if (subs != null) {
current = subs.head; current = subs.head;
while (current != null) { while (current != null) {
sub = current.getValue(); sub = current.getValue();
@ -552,6 +552,7 @@ public class SubscriptionManager {
} }
// CAN NOT RETURN NULL
// ALSO checks to see if the superClass accepts subtypes. // ALSO checks to see if the superClass accepts subtypes.
public final StrongConcurrentSetV8<Subscription> getSuperSubscriptions(Class<?> superType) { public final StrongConcurrentSetV8<Subscription> getSuperSubscriptions(Class<?> superType) {
Map<Class<?>, StrongConcurrentSetV8<Subscription>> local = this.superClassSubscriptions; Map<Class<?>, StrongConcurrentSetV8<Subscription>> local = this.superClassSubscriptions;
@ -564,7 +565,7 @@ public class SubscriptionManager {
StrongConcurrentSetV8<Class<?>> types = getSuperClasses(superType); StrongConcurrentSetV8<Class<?>> types = getSuperClasses(superType);
if (types.isEmpty()) { if (types.isEmpty()) {
local.put(superType, EMPTY_SUBS); local.put(superType, EMPTY_SUBS);
return null; return EMPTY_SUBS;
} }
Map<Class<?>, StrongConcurrentSetV8<Subscription>> local2 = this.subscriptionsPerMessageSingle; Map<Class<?>, StrongConcurrentSetV8<Subscription>> local2 = this.subscriptionsPerMessageSingle;
@ -582,7 +583,7 @@ public class SubscriptionManager {
current1 = current1.next(); current1 = current1.next();
StrongConcurrentSetV8<Subscription> subs = local2.get(superClass); StrongConcurrentSetV8<Subscription> subs = local2.get(superClass);
if (subs != null && !subs.isEmpty()) { if (subs != null) {
current = subs.head; current = subs.head;
while (current != null) { while (current != null) {
sub = current.getValue(); sub = current.getValue();

View File

@ -94,7 +94,7 @@ public class Subscription {
public int count =0; public int count =0;
public int getCount() { public int getCount() {
return count; return this.count;
} }
/** /**
* @return true if there were listeners for this publication, false if there was nothing * @return true if there were listeners for this publication, false if there was nothing
@ -113,43 +113,43 @@ public class Subscription {
while (current != null) { while (current != null) {
listener = current.getValue(); listener = current.getValue();
current = current.next(); current = current.next();
count++; //count++;
// try { try {
// invocation.invoke(listener, handler, handleIndex, message); invocation.invoke(listener, handler, handleIndex, message);
// } catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
// errorHandler.handlePublicationError(new PublicationError() errorHandler.handlePublicationError(new PublicationError()
// .setMessage("Error during invocation of message handler. " + .setMessage("Error during invocation of message handler. " +
// "The class or method is not accessible") "The class or method is not accessible")
// .setCause(e) .setCause(e)
// .setMethodName(handler.getMethodNames()[handleIndex]) .setMethodName(handler.getMethodNames()[handleIndex])
// .setListener(listener) .setListener(listener)
// .setPublishedObject(message)); .setPublishedObject(message));
// } catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
// errorHandler.handlePublicationError(new PublicationError() errorHandler.handlePublicationError(new PublicationError()
// .setMessage("Error during invocation of message handler. " + .setMessage("Error during invocation of message handler. " +
// "Wrong arguments passed to method. Was: " + message.getClass() "Wrong arguments passed to method. Was: " + message.getClass()
// + "Expected: " + handler.getParameterTypes()[0]) + "Expected: " + handler.getParameterTypes()[0])
// .setCause(e) .setCause(e)
// .setMethodName(handler.getMethodNames()[handleIndex]) .setMethodName(handler.getMethodNames()[handleIndex])
// .setListener(listener) .setListener(listener)
// .setPublishedObject(message)); .setPublishedObject(message));
// } catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
// errorHandler.handlePublicationError(new PublicationError() errorHandler.handlePublicationError(new PublicationError()
// .setMessage("Error during invocation of message handler. " + .setMessage("Error during invocation of message handler. " +
// "Message handler threw exception") "Message handler threw exception")
// .setCause(e) .setCause(e)
// .setMethodName(handler.getMethodNames()[handleIndex]) .setMethodName(handler.getMethodNames()[handleIndex])
// .setListener(listener) .setListener(listener)
// .setPublishedObject(message)); .setPublishedObject(message));
// } catch (Throwable e) { } catch (Throwable e) {
// errorHandler.handlePublicationError(new PublicationError() errorHandler.handlePublicationError(new PublicationError()
// .setMessage("Error during invocation of message handler. " + .setMessage("Error during invocation of message handler. " +
// "The handler code threw an exception") "The handler code threw an exception")
// .setCause(e) .setCause(e)
// .setMethodName(handler.getMethodNames()[handleIndex]) .setMethodName(handler.getMethodNames()[handleIndex])
// .setListener(listener) .setListener(listener)
// .setPublishedObject(message)); .setPublishedObject(message));
// } }
} }
return true; return true;
} }