本文整理了Java中org.jboss.threads.JBossExecutors
类的一些代码示例,展示了JBossExecutors
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JBossExecutors
类的具体详情如下:
包路径:org.jboss.threads.JBossExecutors
类名称:JBossExecutors
[英]JBoss thread- and executor-related utility and factory methods.
[中]JBoss线程和执行器相关的实用程序和工厂方法。
代码示例来源:origin: wildfly/wildfly
/**
* Create a new instance.
*
* @param coreThreads the number of threads to create before enqueueing tasks
* @param maxThreads the maximum number of threads to create
* @param keepAliveTime the amount of time that an idle thread should remain active
* @param keepAliveTimeUnit the unit of time for {@code keepAliveTime}
* @param queue the queue to use for tasks
* @param threadFactory the thread factory to use for new threads
* @param blocking {@code true} if the executor should block when the queue is full and no threads are available, {@code false} to use the handoff executor
* @param handoffExecutor the executor which is called when blocking is disabled and a task cannot be accepted, or {@code null} to reject the task
*/
public QueueExecutor(final int coreThreads, final int maxThreads, final long keepAliveTime, final TimeUnit keepAliveTimeUnit, final Queue<Runnable> queue, final ThreadFactory threadFactory, final boolean blocking, final Executor handoffExecutor) {
this(coreThreads, maxThreads, keepAliveTime, keepAliveTimeUnit, queue, threadFactory, blocking, handoffExecutor, JBossExecutors.directExecutor());
}
代码示例来源:origin: wildfly/wildfly
@Override
public ExecutorService apply(ExecutorService executor) {
return JBossExecutors.protectedExecutorService(executor);
}
代码示例来源:origin: wildfly/wildfly
/**
* Create a direct executor which delegates tasks to the given executor, and then clears <b>all</b> thread-local
* data after each task completes (regardless of outcome). You must have the {@link RuntimePermission}{@code ("modifyThread")}
* permission to use this method.
*
* @param delegate the delegate direct executor
* @return a resetting executor
* @throws SecurityException if the caller does not have the {@link RuntimePermission}{@code ("modifyThread")} permission
*/
public static DirectExecutor resettingExecutor(final DirectExecutor delegate) throws SecurityException {
return cleanupExecutor(delegate, threadLocalResetter());
}
代码示例来源:origin: wildfly/wildfly
/**
* Create a thread factory which resets all thread-local storage and delegates to the given thread factory.
* You must have the {@link RuntimePermission}{@code ("modifyThread")} permission to use this method.
*
* @param delegate the delegate thread factory
* @return the resetting thread factory
* @throws SecurityException if the caller does not have the {@link RuntimePermission}{@code ("modifyThread")}
* permission
*/
public static ThreadFactory resettingThreadFactory(final ThreadFactory delegate) throws SecurityException {
return wrappingThreadFactory(resettingExecutor(directExecutor()), delegate);
}
代码示例来源:origin: wildfly/wildfly
/**
* An executor which delegates to another executor, wrapping each task in a task wrapper.
*
* @param taskWrapper the task wrapper
* @param delegate the delegate executor
* @return a wrapping executor
*/
public static Executor wrappingExecutor(final DirectExecutor taskWrapper, final Executor delegate) {
return executor(wrappingExecutor(delegate), taskWrapper);
}
代码示例来源:origin: org.jboss.threads/jboss-threads-metadata
static DirectExecutor createTaskFilterRecursive(final Iterator<Object> it) {
if (! it.hasNext()) {
return JBossExecutors.directExecutor();
case THREAD_NAME: {
final String nextString = (String) it.next();
return JBossExecutors.threadNameExecutor(createTaskFilterRecursive(it), nextString);
return JBossExecutors.threadNameNotateExecutor(createTaskFilterRecursive(it), nextString);
return JBossExecutors.exceptionLoggingExecutor(createTaskFilterRecursive(it), log, level);
return JBossExecutors.resettingExecutor(createTaskFilterRecursive(it));
return JBossExecutors.cleanupExecutor(createTaskFilterRecursive(it), JBossExecutors.contextClassLoaderResetter());
return JBossExecutors.initializingExecutor(createTaskFilterRecursive(it), r);
return JBossExecutors.cleanupExecutor(createTaskFilterRecursive(it), r);
代码示例来源:origin: wildfly/wildfly
/**
* Run a task, invoking the given notifier with the given attachment.
*
* @param task the task
* @param notifier the notifier
* @param attachment the attachment
* @param <R> the task type
* @param <A> the attachment type
*/
public static <R extends Runnable, A> void run(R task, TaskNotifier<? super R, ? super A> notifier, A attachment) {
run(task, directExecutor(), notifier, attachment);
}
代码示例来源:origin: wildfly/wildfly
public Thread newThread(final Runnable r) {
return delegate.newThread(JBossExecutors.executorTask(taskWrapper, r));
}
代码示例来源:origin: wildfly/wildfly
/**
* Create a task that delegates to the given task, preserving the context classloader which was in effect when
* this method was invoked.
*
* @param delegate the delegate runnable
* @return the wrapping runnable
* @throws SecurityException if a security manager exists and the caller does not have the {@code "copyClassLoader"}
* {@link RuntimePermission}.
*/
public static Runnable classLoaderPreservingTask(final Runnable delegate) throws SecurityException {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(COPY_CONTEXT_CLASSLOADER_PERMISSION);
}
return classLoaderPreservingTaskUnchecked(delegate);
}
代码示例来源:origin: wildfly/wildfly
/**
* Create a direct executor which consumes and logs errors that are thrown to the default thread error category
* {@code "org.jboss.threads.errors"}.
*
* @param delegate the executor to delegate to
* @return the new direct executor
*/
public static DirectExecutor exceptionLoggingExecutor(final DirectExecutor delegate) {
return exceptionLoggingExecutor(delegate, THREAD_ERROR_LOGGER);
}
代码示例来源:origin: org.jboss.threads/jboss-threads-metadata
public static ThreadFactory createThreadFactory(final ThreadGroup threadGroup, final Boolean daemon, final Integer priority, final String namePattern, final Thread.UncaughtExceptionHandler exceptionHandler, final Long stackSize, final List<Object> taskFilterObjects) {
return JBossExecutors.wrappingThreadFactory(createTaskFilter(taskFilterObjects), new JBossThreadFactory(threadGroup, daemon, priority, namePattern, exceptionHandler, stackSize));
}
代码示例来源:origin: org.jboss.threads/jboss-threads-metadata
public static Executor createJBossThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, List<Object> taskFilterObjects) {
return JBossExecutors.wrappingExecutor(createTaskFilter(taskFilterObjects), new JBossThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory));
}
代码示例来源:origin: wildfly/wildfly
/**
* Get a {@code Runnable} which, when executed, clears the thread-local storage of the calling thread.
* You must have the {@link RuntimePermission}{@code ("modifyThread")}
* permission to use this method.
*
* @return the runnable
* @throws SecurityException if the caller does not have the {@link RuntimePermission}{@code ("modifyThread")}
* permission
*/
public static Runnable threadLocalResetter() throws SecurityException {
checkAccess(MODIFY_THREAD_PERMISSION);
return THREAD_LOCAL_RESETTER;
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* Create a thread factory which resets all thread-local storage and delegates to the given thread factory.
* You must have the {@link RuntimePermission}{@code ("modifyThread")} permission to use this method.
*
* @param delegate the delegate thread factory
* @return the resetting thread factory
* @throws SecurityException if the caller does not have the {@link RuntimePermission}{@code ("modifyThread")}
* permission
*/
public static ThreadFactory resettingThreadFactory(final ThreadFactory delegate) throws SecurityException {
return wrappingThreadFactory(resettingExecutor(directExecutor()), delegate);
}
代码示例来源:origin: org.jboss.threads/jboss-threads
/**
* Run a task, invoking the given notifier with the given attachment.
*
* @param task the task
* @param notifier the notifier
* @param attachment the attachment
* @param <R> the task type
* @param <A> the attachment type
*/
public static <R extends Runnable, A> void run(R task, TaskNotifier<? super R, ? super A> notifier, A attachment) {
run(task, directExecutor(), notifier, attachment);
}
代码示例来源:origin: org.jboss.threads/jboss-threads
/**
* An executor which delegates to another executor, wrapping each task in a task wrapper.
*
* @param taskWrapper the task wrapper
* @param delegate the delegate executor
* @return a wrapping executor
*/
public static Executor wrappingExecutor(final DirectExecutor taskWrapper, final Executor delegate) {
return executor(wrappingExecutor(delegate), taskWrapper);
}
代码示例来源:origin: wildfly/wildfly
public void execute(final DirectExecutor directExecutor, final Runnable task) throws RejectedExecutionException {
execute(JBossExecutors.executorTask(directExecutor, task));
}
}
代码示例来源:origin: wildfly/wildfly
final Runnable realRunnable = JBossExecutors.classLoaderPreservingTaskUnchecked(runnable);
int result;
if (TAIL_LOCK) synchronized (tailLock) {
代码示例来源:origin: org.jboss.threads/jboss-threads
/**
* Create a direct executor which consumes and logs errors that are thrown to the default thread error category
* {@code "org.jboss.threads.errors"}.
*
* @param delegate the executor to delegate to
* @return the new direct executor
*/
public static DirectExecutor exceptionLoggingExecutor(final DirectExecutor delegate) {
return exceptionLoggingExecutor(delegate, THREAD_ERROR_LOGGER);
}
代码示例来源:origin: org.jboss.threads/jboss-threads
/**
* Get a {@code Runnable} which, when executed, clears the thread-local storage of the calling thread.
* You must have the {@link RuntimePermission}{@code ("modifyThread")}
* permission to use this method.
*
* @return the runnable
* @throws SecurityException if the caller does not have the {@link RuntimePermission}{@code ("modifyThread")}
* permission
*/
public static Runnable threadLocalResetter() throws SecurityException {
checkAccess(MODIFY_THREAD_PERMISSION);
return THREAD_LOCAL_RESETTER;
}
内容来源于网络,如有侵权,请联系作者删除!