forked from dan200/ComputerCraft
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dan200#395 from SquidDev-CC/ComputerCraft/feature/…
…websocket Websocket support
- Loading branch information
Showing
9 changed files
with
568 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/dan200/computercraft/core/apis/http/HTTPExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* This file is part of ComputerCraft - http://www.computercraft.info | ||
* Copyright Daniel Ratcliffe, 2011-2017. Do not distribute without permission. | ||
* Send enquiries to dratcliffe@gmail.com | ||
*/ | ||
|
||
package dan200.computercraft.core.apis.http; | ||
|
||
import com.google.common.util.concurrent.ListeningExecutorService; | ||
import com.google.common.util.concurrent.MoreExecutors; | ||
import com.google.common.util.concurrent.ThreadFactoryBuilder; | ||
import io.netty.channel.EventLoopGroup; | ||
import io.netty.channel.nio.NioEventLoopGroup; | ||
|
||
import java.util.concurrent.SynchronousQueue; | ||
import java.util.concurrent.ThreadPoolExecutor; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* Just a shared object for executing simple HTTP related tasks. | ||
*/ | ||
public final class HTTPExecutor | ||
{ | ||
public static final ListeningExecutorService EXECUTOR = MoreExecutors.listeningDecorator( new ThreadPoolExecutor( | ||
4, Integer.MAX_VALUE, | ||
60L, TimeUnit.SECONDS, | ||
new SynchronousQueue<Runnable>(), | ||
new ThreadFactoryBuilder() | ||
.setDaemon( true ) | ||
.setPriority( Thread.MIN_PRIORITY + (Thread.NORM_PRIORITY - Thread.MIN_PRIORITY) / 2 ) | ||
.setNameFormat( "ComputerCraft-HTTP-%d" ) | ||
.build() | ||
) ); | ||
|
||
public static final EventLoopGroup LOOP_GROUP = new NioEventLoopGroup( 4, new ThreadFactoryBuilder() | ||
.setDaemon( true ) | ||
.setPriority( Thread.MIN_PRIORITY + (Thread.NORM_PRIORITY - Thread.MIN_PRIORITY) / 2 ) | ||
.setNameFormat( "ComputerCraft-Netty-%d" ) | ||
.build() | ||
); | ||
|
||
private HTTPExecutor() | ||
{ | ||
} | ||
} |
Oops, something went wrong.