This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new fa352e4ed2 Add a simple Loom based Executor fa352e4ed2 is described below commit fa352e4ed20a58783dfc10f205d2e17fa690554d Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Oct 20 14:27:13 2022 +0100 Add a simple Loom based Executor --- .../org/apache/catalina/core/LoomExecutor.java | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/modules/loom/src/main/java/org/apache/catalina/core/LoomExecutor.java b/modules/loom/src/main/java/org/apache/catalina/core/LoomExecutor.java new file mode 100644 index 0000000000..d4ae23b021 --- /dev/null +++ b/modules/loom/src/main/java/org/apache/catalina/core/LoomExecutor.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.core; + +import org.apache.catalina.Executor; +import org.apache.catalina.LifecycleException; +import org.apache.catalina.LifecycleState; +import org.apache.catalina.util.LifecycleMBeanBase; + +/** + * An executor that uses a new virtual thread for each task. + */ +public class LoomExecutor extends LifecycleMBeanBase implements Executor { + + private String name; + private Thread.Builder threadBuilder; + + public void setName(String name) { + this.name = name; + } + + @Override + public String getName() { + return name; + } + + @Override + public void execute(Runnable command) { + threadBuilder.start(command); + } + + @Override + protected void startInternal() throws LifecycleException { + threadBuilder = Thread.ofVirtual().name(getName() + "-", 0); + setState(LifecycleState.STARTING); + } + + @Override + protected void stopInternal() throws LifecycleException { + threadBuilder = null; + setState(LifecycleState.STOPPING); + } + + @Override + protected String getDomainInternal() { + // No way to navigate to Engine. Needs to have domain set. + return null; + } + + @Override + protected String getObjectNameKeyProperties() { + return "type=Executor,name=" + getName(); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org