Skip to content

Commit

Permalink
1. update sofa-common-tools 1.3.15 (#198)
Browse files Browse the repository at this point in the history
1. update sofa-common-tools 1.3.15
2. add SofaVirtualThreadFactory api for low java version sdk

---------

Co-authored-by: “HzjNeverStop” <“441627022@qq.com”>
  • Loading branch information
HzjNeverStop and “HzjNeverStop” committed Dec 27, 2023
1 parent ec236c2 commit 68b0322
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.alipay.sofa.common</groupId>
<artifactId>sofa-common-tools</artifactId>
<version>1.3.14</version>
<version>1.3.15</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* 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 com.alipay.sofa.common.thread.virtual;

import java.util.concurrent.ExecutorService;

/**
* Delegate for virtual thread handling on JDK 21.
* This is a dummy version for reachability on JDK less than 21.
*
* @author huzijie
* @version SofaVirtualThreadFactory.java, v 0.1 2023年11月20日 3:57 PM huzijie Exp $
*/
public class SofaVirtualThreadFactory {

/**
* Create a virtual thread with name.
*
* @param name thread name
* @param runnable task to run with thread
* @return a virtual thread with runnable
* @since 2.1.0
*/
public static Thread ofThread(String name, Runnable runnable) {
throw new UnsupportedOperationException("Virtual threads not supported on JDK <21");
}

/**
* Create a virtual thread with name.
*
* @param name thread name
* @param inheritInheritableThreadLocals {@code true} to inherit, {@code false} to not inherit
* @param uncaughtExceptionHandler uncaught exception handler
* @param runnable task to run with thread
* @return a virtual thread with runnable
* @since 2.1.0
*/

public static Thread ofThread(String name, boolean inheritInheritableThreadLocals,
Thread.UncaughtExceptionHandler uncaughtExceptionHandler,
Runnable runnable) {
throw new UnsupportedOperationException("Virtual threads not supported on JDK <21");
}

/**
* Creates an Executor that starts a new virtual Thread for each task.
* The number of threads created by the Executor is unbounded.
*
* @param prefix thread prefix
* @return a new executor that creates a new virtual Thread for each task
* @since 2.1.0
*/
public static ExecutorService ofExecutorService(String prefix) {
throw new UnsupportedOperationException("Virtual threads not supported on JDK <21");
}

/**
* Creates an Executor that starts a new virtual Thread for each task.
* The number of threads created by the Executor is unbounded.
*
* @param prefix thread prefix
* @param start the starting value of the counter
* @param inheritInheritableThreadLocals {@code true} to inherit, {@code false} to not inherit
* @param uncaughtExceptionHandler uncaught exception handler
* @return a new executor that creates a new virtual Thread for each task
* @since 2.1.0
*/
public static ExecutorService ofExecutorService(String prefix,
long start,
boolean inheritInheritableThreadLocals,
Thread.UncaughtExceptionHandler uncaughtExceptionHandler) {
throw new UnsupportedOperationException("Virtual threads not supported on JDK <21");
}
}

0 comments on commit 68b0322

Please sign in to comment.