funky-eyes commented on code in PR #8023: URL: https://github.com/apache/incubator-seata/pull/8023#discussion_r3152066333
########## threadpool-loom/src/main/java/org/apache/seata/common/thread/VirtualScheduledThreadPoolExecutor.java: ########## @@ -0,0 +1,31 @@ +/* + * 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.seata.common.thread; + +import java.util.concurrent.RejectedExecutionHandler; +import java.util.concurrent.ScheduledThreadPoolExecutor; + +/** + * Virtual-thread-backed scheduled thread pool implementation. + */ +public class VirtualScheduledThreadPoolExecutor extends ScheduledThreadPoolExecutor { + + public VirtualScheduledThreadPoolExecutor( + String threadPrefix, int corePoolSize, boolean daemon, RejectedExecutionHandler rejectedHandler) { + super(corePoolSize, VirtualThreadFactoryHelper.newThreadFactory(threadPrefix, daemon), rejectedHandler); Review Comment: > Fair point on JEP 491 — agreed my pinning argument was off, ReentrantLock + Condition.await in DelayedWorkQueue.take() goes through LockSupport.park and unmounts cleanly on JDK 21+ already, so this isn't a pinning bug. Withdrawing that part. The remaining question is whether wrapping ScheduledThreadPoolExecutor with a virtual ThreadFactory actually buys us anything — concurrency is still capped at corePoolSize because that's how STPE schedules tasks, so the unbounded-virtual-threads property doesn't really apply. Not a blocker, just curious whether you measured a difference vs the platform path. Threads related to scheduled tasks will consume additional system resources when using platform threads. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
