Skip to content

Commit

Permalink
[misc] initialize read-ahead scheduler only if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Sep 5, 2017
1 parent 348d294 commit abba398
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Expand Up @@ -61,6 +61,7 @@
import org.mariadb.jdbc.internal.util.dao.ClientPrepareResult;
import org.mariadb.jdbc.internal.util.dao.PrepareResult;
import org.mariadb.jdbc.internal.util.dao.ServerPrepareResult;
import org.mariadb.jdbc.internal.util.scheduler.SchedulerServiceProviderHolder;

import java.io.IOException;
import java.sql.SQLException;
Expand Down Expand Up @@ -234,6 +235,13 @@ private PrepareResult executeBatchStandard(int paramCount) throws SQLException {
futureReadTask = new FutureTask<AsyncMultiReadResult>(new AsyncMultiRead(comStmtPrepare, status,
protocol, false, this, paramCount,
results, parametersList, queries, prepareResult));
if (AbstractQueryProtocol.readScheduler == null) {
synchronized (AbstractQueryProtocol.class) {
if (AbstractQueryProtocol.readScheduler == null) {
AbstractQueryProtocol.readScheduler = SchedulerServiceProviderHolder.getBulkScheduler();
}
}
}
AbstractQueryProtocol.readScheduler.execute(futureReadTask);
}
}
Expand Down
Expand Up @@ -121,13 +121,6 @@ public class AbstractQueryProtocol extends AbstractConnectProtocol implements Pr

public AbstractQueryProtocol(final UrlParser urlParser, final ReentrantLock lock) {
super(urlParser, lock);
if (options.useBatchMultiSend && readScheduler == null) {
synchronized (AbstractQueryProtocol.class) {
if (readScheduler == null) {
readScheduler = SchedulerServiceProviderHolder.getBulkScheduler();
}
}
}
logQuery = new LogQueryTool(options);
}

Expand Down

0 comments on commit abba398

Please sign in to comment.