Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[CONJ-297] Code improvement after "jentfoo" remarks
  • Loading branch information
rusher committed May 18, 2016
1 parent 5a2a4e5 commit ffe9527
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
11 changes: 1 addition & 10 deletions src/main/java/org/mariadb/jdbc/MariaDbStatement.java
Expand Up @@ -68,7 +68,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS

public class MariaDbStatement implements Statement, Cloneable {
//timeout scheduler
private static volatile ScheduledThreadPoolExecutor timeoutScheduler = null;
private static final ScheduledExecutorService timeoutScheduler = SchedulerServiceProviderHolder.getTimeoutScheduler();

/**
* the protocol used to talk to the server.
Expand Down Expand Up @@ -155,15 +155,6 @@ public Protocol getProtocol() {
protected void setTimerTask() {
assert (timerTaskFuture == null);

if (timeoutScheduler == null) {
//Scheduler initialisation
synchronized (connection) {
if (timeoutScheduler == null) {
timeoutScheduler = SchedulerServiceProviderHolder.getSchedulerProvider().getTimeoutScheduler();
}
}
}

timerTaskFuture = timeoutScheduler.schedule(new Runnable() {
@Override
public void run() {
Expand Down
Expand Up @@ -117,7 +117,6 @@ public static DynamicSizedSchedulerInterface getScheduler(int initialThreadCount
return getSchedulerProvider().getScheduler(initialThreadCount);
}


/**
* Get a fixed sized scheduler directly with the current set provider.
*
Expand All @@ -128,6 +127,15 @@ public static ScheduledExecutorService getFixedSizeScheduler(int initialThreadCo
return getSchedulerProvider().getFixedSizeScheduler(initialThreadCount);
}

/**
* Get a scheduler to handle timeout.
*
* @return Scheduler capable of providing the needed thread count
*/
public static ScheduledExecutorService getTimeoutScheduler() {
return getSchedulerProvider().getTimeoutScheduler();
}

/**
* <p>Provider for thread pools which allow scheduling capabilities. It is expected that the
* thread pools entire lifecycle (start to stop) is done through the same provider instance.</p>
Expand Down

0 comments on commit ffe9527

Please sign in to comment.