Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
aashikam committed Jul 12, 2024
1 parent a88ceaf commit d6a0447
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

package io.ballerina.stdlib.sql.datasource;

import io.ballerina.stdlib.sql.Constants;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import static io.ballerina.stdlib.sql.Constants.BALLERINA_SQL_MAX_POOL_SIZE;

/**
* Class to hold the static cachedThreadPool for SQL.
*/
Expand All @@ -34,7 +34,10 @@ public class SQLWorkerThreadPool {
private SQLWorkerThreadPool() {
}

static final int MAX_POOL_SIZE = Integer.parseInt(System.getProperty(Constants.BALLERINA_SQL_MAX_POOL_SIZE, "50"));
static final int MAX_POOL_SIZE = Integer.parseInt(
System.getenv(BALLERINA_SQL_MAX_POOL_SIZE) != null ?
System.getenv(BALLERINA_SQL_MAX_POOL_SIZE) : "50"
);

// This is similar to cachedThreadPool util from Executors.newCachedThreadPool(..); but with upper cap on threads
public static final ExecutorService SQL_EXECUTOR_SERVICE = new ThreadPoolExecutor(0, MAX_POOL_SIZE,
Expand Down

0 comments on commit d6a0447

Please sign in to comment.