1 /*
2  * Copyright 2002-2017 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 module hunt.stomp.simp.config.TaskExecutorRegistration;
18 
19 
20 // import hunt.framework.scheduling.concurrent.ThreadPoolTaskExecutor;
21 
22 
23 // /**
24 //  * A registration class for customizing the properties of {@link ThreadPoolTaskExecutor}.
25 //  *
26 //  * @author Rossen Stoyanchev
27 //  * @author Juergen Hoeller
28 //  * @since 4.0
29 //  */
30 // public class TaskExecutorRegistration {
31 
32 // 	private final ThreadPoolTaskExecutor taskExecutor;
33 
34 	
35 // 	private Integer corePoolSize;
36 
37 	
38 // 	private Integer maxPoolSize;
39 
40 	
41 // 	private Integer keepAliveSeconds;
42 
43 	
44 // 	private Integer queueCapacity;
45 
46 
47 // 	/**
48 // 	 * Create a new {@code TaskExecutorRegistration} for a default
49 // 	 * {@link ThreadPoolTaskExecutor}.
50 // 	 */
51 // 	public TaskExecutorRegistration() {
52 // 		this.taskExecutor = new ThreadPoolTaskExecutor();
53 // 		this.taskExecutor.setCorePoolSize(Runtime.getRuntime().availableProcessors() * 2);
54 // 		this.taskExecutor.setAllowCoreThreadTimeOut(true);
55 // 	}
56 
57 // 	/**
58 // 	 * Create a new {@code TaskExecutorRegistration} for a given
59 // 	 * {@link ThreadPoolTaskExecutor}.
60 // 	 * @param taskExecutor the executor to use
61 // 	 */
62 // 	public TaskExecutorRegistration(ThreadPoolTaskExecutor taskExecutor) {
63 // 		assert(taskExecutor, "ThreadPoolTaskExecutor must not be null");
64 // 		this.taskExecutor = taskExecutor;
65 // 	}
66 
67 
68 // 	/**
69 // 	 * Set the core pool size of the ThreadPoolExecutor.
70 // 	 * <p><strong>NOTE:</strong> The core pool size is effectively the max pool size
71 // 	 * when an unbounded {@link #queueCapacity(int) queueCapacity} is configured
72 // 	 * (the default). This is essentially the "Unbounded queues" strategy as explained
73 // 	 * in {@link java.util.concurrent.ThreadPoolExecutor ThreadPoolExecutor}. When
74 // 	 * this strategy is used, the {@link #maxPoolSize(int) maxPoolSize} is ignored.
75 // 	 * <p>By default this is set to twice the value of
76 // 	 * {@link Runtime#availableProcessors()}. In an application where tasks do not
77 // 	 * block frequently, the number should be closer to or equal to the number of
78 // 	 * available CPUs/cores.
79 // 	 */
80 // 	public TaskExecutorRegistration corePoolSize(int corePoolSize) {
81 // 		this.corePoolSize = corePoolSize;
82 // 		return this;
83 // 	}
84 
85 // 	/**
86 // 	 * Set the max pool size of the ThreadPoolExecutor.
87 // 	 * <p><strong>NOTE:</strong> When an unbounded
88 // 	 * {@link #queueCapacity(int) queueCapacity} is configured (the default), the
89 // 	 * max pool size is effectively ignored. See the "Unbounded queues" strategy
90 // 	 * in {@link java.util.concurrent.ThreadPoolExecutor ThreadPoolExecutor} for
91 // 	 * more details.
92 // 	 * <p>By default this is set to {@code Integer.MAX_VALUE}.
93 // 	 */
94 // 	public TaskExecutorRegistration maxPoolSize(int maxPoolSize) {
95 // 		this.maxPoolSize = maxPoolSize;
96 // 		return this;
97 // 	}
98 
99 // 	/**
100 // 	 * Set the time limit for which threads may remain idle before being terminated.
101 // 	 * If there are more than the core number of threads currently in the pool,
102 // 	 * after waiting this amount of time without processing a task, excess threads
103 // 	 * will be terminated. This overrides any value set in the constructor.
104 // 	 * <p>By default this is set to 60.
105 // 	 */
106 // 	public TaskExecutorRegistration keepAliveSeconds(int keepAliveSeconds) {
107 // 		this.keepAliveSeconds = keepAliveSeconds;
108 // 		return this;
109 // 	}
110 
111 // 	/**
112 // 	 * Set the queue capacity for the ThreadPoolExecutor.
113 // 	 * <p><strong>NOTE:</strong> when an unbounded {@code queueCapacity} is configured
114 // 	 * (the default), the core pool size is effectively the max pool size. This is
115 // 	 * essentially the "Unbounded queues" strategy as explained in
116 // 	 * {@link java.util.concurrent.ThreadPoolExecutor ThreadPoolExecutor}. When
117 // 	 * this strategy is used, the {@link #maxPoolSize(int) maxPoolSize} is ignored.
118 // 	 * <p>By default this is set to {@code Integer.MAX_VALUE}.
119 // 	 */
120 // 	public TaskExecutorRegistration queueCapacity(int queueCapacity) {
121 // 		this.queueCapacity = queueCapacity;
122 // 		return this;
123 // 	}
124 
125 
126 // 	protected ThreadPoolTaskExecutor getTaskExecutor() {
127 // 		if (this.corePoolSize !is null) {
128 // 			this.taskExecutor.setCorePoolSize(this.corePoolSize);
129 // 		}
130 // 		if (this.maxPoolSize !is null) {
131 // 			this.taskExecutor.setMaxPoolSize(this.maxPoolSize);
132 // 		}
133 // 		if (this.keepAliveSeconds !is null) {
134 // 			this.taskExecutor.setKeepAliveSeconds(this.keepAliveSeconds);
135 // 		}
136 // 		if (this.queueCapacity !is null) {
137 // 			this.taskExecutor.setQueueCapacity(this.queueCapacity);
138 // 		}
139 // 		return this.taskExecutor;
140 // 	}
141 
142 // }