ThreadingAdapter

Package: MachII.util.threading
Base threading adapter component. This is a base class. Please instantiate a concrete adapter.

<!--- License: Copyright 2008 GreatBizTools, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Copyright: GreatBizTools, LLC Author: Peter J. Farrell (peter@mach-ii.com) $Id: MessageHandler.cfc 549 2007-11-11 22:19:47Z peterfarrell $ Created version: 1.6.0 Updated version: 1.6.0 Notes: --->

Method Summary
public ThreadingAdapter init()

This is the base class. Please instantiate a concrete adapter.

public boolean allowThreading()

Returns a boolean if threading is allowed.

private string createThreadId(string method)

Creates a random tread id. Does not use UUID for performance reasons.

public void join(struct threadIds)

Joins a group of threads.

public void run(any callback, string method, [struct parameters="#StructNew()#"])

Runs a thread.

Method Detail
allowThreading

public boolean allowThreading( )

Returns a boolean if threading is allowed.

Parameters:

Code:

	<cffunction name="allowThreading" access="public" returntype="boolean" output="false"
		hint="Returns a boolean if threading is allowed.">
		<cfreturn variables.allowThreading />
	</cffunction> 

createThreadId

private string createThreadId( string method )

Creates a random tread id. Does not use UUID for performance reasons.

Parameters:
string method

Code:

	<cffunction name="createThreadId" access="private" returntype="string" output="false"
		hint="Creates a random tread id. Does not use UUID for performance reasons.">
		<cfargument name="method" type="string" required="true"
			hint="Name of method. Adds additional data for seed.">
		<cfreturn Hash(getTickCount() & RandRange(0, 100000) & RandRange(0, 100000) & arguments.method) />
	</cffunction> 

init

public ThreadingAdapter init( )

This is the base class. Please instantiate a concrete adapter.

Parameters:

Code:

	<cffunction name="init" access="public" returntype="ThreadingAdapter" output="false"
		hint="This is the base class. Please instantiate a concrete adapter.">
		<cfreturn this />
	</cffunction> 

join

public void join( struct threadIds )

Joins a group of threads.

Parameters:
struct threadIds

Code:

	<cffunction name="join" access="public" returntype="void" output="false"
		hint="Joins a group of threads.">
		<cfargument name="threadIds" type="struct" required="true" />
		<cfabort showerror="This is the base class. Please instantiate a concrete adapter." />
	</cffunction> 

run

public void run( any callback, string method, [struct parameters="#StructNew()#"] )

Runs a thread.

Parameters:
any callback
string method
[struct parameters="#StructNew()#"]

Code:

	<cffunction name="run" access="public" returntype="void" output="false"
		hint="Runs a thread.">
		<cfargument name="callback" type="any" required="true" />
		<cfargument name="method" type="string" required="true" />
		<cfargument name="parameters" type="struct" required="false" default="#StructNew()#" />
		<cfabort showerror="This is the base class. Please instantiate a concrete adapter." />
	</cffunction>