Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions AbstractCompletionTask.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ component output="false" accessors="true"{
}

public function process( array results ){
writeLog("OVERRIDE ME!");
logInfo("OVERRIDE ME!");
}


Expand Down Expand Up @@ -52,7 +52,7 @@ component output="false" accessors="true"{
if( NOT arrayIsEmpty(allResults) ){
process( allResults );
} else if( getLoggingEnabled() ) {
writeLog("Results were empty...");
logInfo("Results were empty...");
}
}
catch( Any e )
Expand All @@ -62,6 +62,10 @@ component output="false" accessors="true"{

}

function logInfo( message ){
writeLog(arguments.message);
}

function logError( error, message ){
writeLog("#message# : #error.message#; #error.detail#");
lastError = error;
Expand Down
8 changes: 4 additions & 4 deletions AbstractExecutorService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@ component output="false" accessors="true"{

public function start(){
//This will be overridden by implementers
status = "started";
variables.status = "started";
return this;
}

public function stop( timeout=100, timeUnit="#objectFactory.MILLISECONDS#" ){
shutdownAllExecutors( timeout, timeUnit );
status = "stopped";
variables.status = "stopped";
return this;
}

public function pause(){
status = "paused";
variables.status = "paused";
return this;
}

public function unPause(){
if( isStopped() ){
start();
} else {
status = "started";
variables.status = "started";
}
return this;
}
Expand Down
22 changes: 11 additions & 11 deletions ScheduledThreadPoolExecutor.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ component extends="ExecutorService" accessors="true" output="false"{

super.init( serviceName, maxConcurrent, -1, objectFactory );

storedTasks = {};
variables.storedTasks = {};
return this;
}

public function start(){
variables.scheduledExecutor = objectFactory.createScheduledThreadPoolExecutor( maxConcurrent );
variables.scheduledExecutor = variables.objectFactory.createScheduledThreadPoolExecutor( maxConcurrent );

//store the executor for sane destructability
storeExecutor( "scheduledExecutor", variables.scheduledExecutor );
Expand All @@ -25,8 +25,8 @@ component extends="ExecutorService" accessors="true" output="false"{

public function scheduleAtFixedRate( id, task, initialDelay, period, timeUnit="#objectFactory.SECONDS#" ){
cancelTask( id );
var future = scheduledExecutor.scheduleAtFixedRate(
objectFactory.createRunnableProxy( task ),
var future = variables.scheduledExecutor.scheduleAtFixedRate(
variables.objectFactory.createRunnableProxy( task ),
initialDelay,
period,
timeUnit
Expand All @@ -37,8 +37,8 @@ component extends="ExecutorService" accessors="true" output="false"{

public function scheduleWithFixedDelay( id, task, initialDelay, delay, timeUnit="#objectFactory.SECONDS#" ){
cancelTask( id );
var future = scheduledExecutor.scheduleWithFixedDelay(
objectFactory.createRunnableProxy( task ),
var future = variables.scheduledExecutor.scheduleWithFixedDelay(
variables.objectFactory.createRunnableProxy( task ),
initialDelay,
delay,
timeUnit
Expand All @@ -48,7 +48,7 @@ component extends="ExecutorService" accessors="true" output="false"{
}

package function storeTask( id, task, future ){
storedTasks[ id ] = { task = task, future = future };
variables.storedTasks[ id ] = { task = task, future = future };
return this;
}

Expand All @@ -57,12 +57,12 @@ component extends="ExecutorService" accessors="true" output="false"{
The 'future' is the <ScheduledFuture> object returned when submitting the task
*/
public function cancelTask( id ){
if( structKeyExists( storedTasks, id ) ){
var task = storedTasks[ id ];
if( structKeyExists( variables.storedTasks, id ) ){
var task = variables.storedTasks[ id ];
var future = task.future;
future.cancel( true );
scheduledExecutor.purge();
structDelete( storedTasks, id );
variables.scheduledExecutor.purge();
structDelete( variables.storedTasks, id );
return task;
}
}
Expand Down