ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/util/threads/InlineExecutorService.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/util/threads/InlineExecutorService.java
Status
scanned
Type
file
Name
InlineExecutorService.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
2891 (2.8 KB)
MD5
dabfd047556f078d8dc2b22ed6957827
SHA1
0f1c77ae1ddd1d7ac1c838ad133252174ecda477
SHA256
2fd3e4143c97362ba28b4ee0d7dae206452092eaa456be31de8452bdd8e02437
SHA512

      
    
SHA1_git
83dad9fb46de7defd856a8824561775df47f5bca
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
InlineExecutorService.java | 2.8 KB |

/* * 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.tomcat.util.threads; import java.util.List; import java.util.concurrent.AbstractExecutorService; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; public class InlineExecutorService extends AbstractExecutorService { private volatile boolean shutdown; private volatile boolean taskRunning; private volatile boolean terminated; private final Object lock = new Object(); @Override public void shutdown() { shutdown = true; synchronized (lock) { terminated = !taskRunning; } } @Override public List<Runnable> shutdownNow() { shutdown(); return List.of(); } @Override public boolean isShutdown() { return shutdown; } @Override public boolean isTerminated() { return terminated; } @Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { long timeoutExpiry = System.nanoTime() + unit.toNanos(timeout); long timeoutMillis = unit.toMillis(timeout); synchronized (lock) { /* * Spurious wake-ups are possible. Keep waiting until the service has been terminated or the timeout has * expired. */ while (!terminated && timeoutMillis > 0) { lock.wait(timeoutMillis); timeoutMillis = (timeoutExpiry - System.nanoTime()) / 1_000_000; } return terminated; } } @Override public void execute(Runnable command) { synchronized (lock) { if (shutdown) { throw new RejectedExecutionException(); } taskRunning = true; } command.run(); synchronized (lock) { taskRunning = false; if (shutdown) { terminated = true; lock.notifyAll(); } } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
42.2
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9