Skip to content

Commit

Permalink
- New MessageProcessingPolicy 'PassRegularMessagesUpDirectly'
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Mar 30, 2023
1 parent ae71c93 commit b5e0e0a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/org/jgroups/protocols/TP.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,10 @@ public <T extends Protocol> T setLevel(String level) {
public void setMessageProcessingPolicy(String policy) {
if(policy == null)
return;

msg_processing_policy=policy.startsWith("submit")? new SubmitToThreadPool() :
policy.startsWith("max")? new MaxOneThreadPerSender() : null;
policy.startsWith("max")? new MaxOneThreadPerSender() :
policy.startsWith("direct")? new PassRegularMessagesUpDirectly() : null;
try {
if(msg_processing_policy == null) {
Class<MessageProcessingPolicy> clazz=(Class<MessageProcessingPolicy>)Util.loadClass(policy, getClass());
Expand Down
38 changes: 38 additions & 0 deletions src/org/jgroups/util/PassRegularMessagesUpDirectly.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.jgroups.util;

import org.jgroups.Message;

/**
* {@link org.jgroups.stack.MessageProcessingPolicy} which passes regular messages and message batches up directly
* (on the same thread), but passes OOB messages to the thread pool.
* @author Bela Ban
* @since 5.2.14
*/
public class PassRegularMessagesUpDirectly extends SubmitToThreadPool {

@Override
public boolean loopback(Message msg, boolean oob) {
if(oob)
return super.loopback(msg, oob);
tp.passMessageUp(msg, null, false, msg.getDest() == null, false);
return true;
}

@Override
public boolean process(Message msg, boolean oob) {
if(oob)
return super.process(msg, oob);
SingleMessageHandler smh=new SingleMessageHandler(msg);
smh.run();
return true;
}

@Override
public boolean process(MessageBatch batch, boolean oob) {
if(oob)
return super.process(batch, oob);
BatchHandler bh=new BatchHandler(batch);
bh.run();
return true;
}
}

0 comments on commit b5e0e0a

Please sign in to comment.