<source><name>Hemi.util.thread</name><project><name>Hemi JavaScript Framework</name><url-title>Hemi JavaScript Framework</url-title><url>/Hemi/</url></project><package><path>Hemi.util.thread</path><library>Hemi</library><description>The Thread class provides a psuedo-thread implementation for Framework Objects.  Each thread is sensitive to the object lifecycle, and can stop itself when the object is destroyed or when the framework is shutdown.</description><static-class><name>Thread</name><description>Creates a psuedo asynchronous thread.</description><method><name>newInstance</name><param name="o" type="object">A registered object.</param><return-value name="t" type="Thread">A new ThreadInstance.</return-value><description>Creates a new instance of a psuedo thread.  The thread is bound to the object lifetime of the specified object, so that when the object is explicitly destroyed or removed from the ObjectRegistry, the thread will also terminate.</description></method><example implementation="1"><description>Demonstrate how to use the Thread component.</description><name>Example Thread #1</name><code>var MyThreadedObject = {</code><code>   handle_thread_run : function(oThread){</code><code>      /* basic demo */</code><code>      document.title = (new Date()).getTime();</code><code>   }</code><code>};</code><code>/* Prepare the MyThreadedObject for use with Engine */</code><code>Hemi.prepareObject("CustomThread","1.0",true,MyThreadedObject);</code><code>/* Create a new thread for MyThreadedObject*/</code><code>var oThread = Hemi.util.thread.newInstance(MyThreadedObject);</code><code>/* run the thread every 5 seconds */</code><code>oThread.run(5000);</code></example></static-class><class><name>ThreadInstance</name><description>A psuedo thread that is created by invoking the static <i>thread</i> class <i>newInstance</i> method.</description><method virtual="1"><name>handle_thread_start</name><param name="t" type="ThreadInstance">An instance of a pseudo thread.</param><description>Invoked when the thread is starting.</description></method><method virtual="1"><name>handle_thread_stop</name><param name="t" type="ThreadInstance">An instance of a pseudo thread.</param><description>Invoked when the thread is shutting down.</description></method><method virtual="1"><name>handle_thread_run</name><param name="t" type="ThreadInstance">An instance of a pseudo thread.</param><description>Invoked when the thread is running an iteration.</description></method><property type="String" get="1" internal="1"><name>object_id</name><description>Unique instance identifier.</description></property><property type="String" get="1" internal="1"><name>object_version</name><description>Version of the object class.</description></property><property type="String" get="1" internal="1"><name>object_type</name><description>The type of this object.</description></property><property type="int" get="1" internal="1"><name>ready_state</name><description>Object load and execution state.  Follows: 0 unitialized, 1 through 3 variant, 4 ready, 5 destroyed.</description></property><property type="object" get="1" internal="1"><name>object_config</name><description>Object API structure for storing sub structures: object_config.pointers and object_config.status.</description></property><method><name>getObjectId</name><return-value name="i" type="String">The unique object instance id.</return-value><description>Returns the unique id of the object.</description></method><method><name>getObjectType</name><return-value name="t" type="String">The type of the object instance.</return-value><description>Returns the type of the object.</description></method><method><name>getObjectVersion</name><return-value name="v" type="String">The version of the object instance.</return-value><description>Returns the version of the object.</description></method><method><name>getReadyState</name><return-value name="s" type="int">The object ready state.</return-value><description>Returns the state of the object.</description></method><method><name>getStatus</name><return-value name="o" type="object">The object_config.status substructure.</return-value><description>Returns the object_config.status sub structure.</description></method><method><name>getPointers</name><return-value name="o" type="object">The object_config.pointers substructure.</return-value><description>Returns the object_config.pointers sub structure.</description></method><method><name>restart</name><description>Restarts the thread interval.</description><return-value type="boolean" name="b">Bit indicating whether the thread was restarted.</return-value></method><method><name>getLastInterval</name><description>Returns the delay interval used to start the thread.</description><return-value type="int" name="i">The interval in milliseconds used to start the thread.</return-value></method><method><name>run</name><param name="d" type="int" optional="1" default="1000">Delay in execution between thread iterations.</param><param name="b" type="boolean" optional="1">Bit indicating whether the virtual handle_thread_stop method should be suppressed.</param><description>Runs the thread with the specifed delay.</description><return-value type="boolean" name="b">Bit indicating whether the thread started running.</return-value></method><method><name>allStop</name><description>Invokes the <i>stop</i> method and prevents the thread from further execution.</description></method><method><name>stop</name><description>Stops the thread.</description><param name="b" type="boolean" optional="1">Bit indicating whether the virtual handle_thread_stop method should be suppressed.</param><return-value type="boolean" name="b">Bit indicating whether the thread was stopped.</return-value></method><method><name>getIsRunning</name><description>Returns true if the thread is running, false otherwise.</description><return-value type="boolean" name="b">Bit indicating whether the thread is running.</return-value></method><method><name>getIsRunnable</name><description>Returns true if the thread can be run.</description><return-value type="boolean" name="b">Bit indicating whether the thread can be run.</return-value></method><method><name>destroy</name><description>Prepares the object for destruction.</description></method></class></package><index><description>The Thread class provides a psuedo-thread implementation for Framework Objects.  Each thread is sensitive to the object lifecycle, and can stop itself when the object is destroyed or when the framework is shutdown.</description><url>Hemi_api.html</url><url-title>API Index</url-title></index></source>
