
Rebuilding the Demo Host Software
Additional Procedures
A-17
uses or by the function itself if it detects some irregularity. That exception
travels up the call stack until it is caught. If no function catches it, the
application exits in an error with its call stack listed.
This behavior frees us from having to check the return status frequently.
Instead, we catch exceptions by enclosing function(s) whose execution
can result in an exception in a "try-catch" block like the following:
try {
function(s) called here
} catch (e) {
// we're here only if an error occurred
print ("error occurred, reason: " + e)
}
In the demo application, the Main.js script contains examples of "try-
catch" blocks.
A.4.7
Threading
The host-side application is multi-threaded.
The
main thread
runs the main() function, looping to see if the
display should be refreshed, dispatching any events, and exiting
when the window is closed. Each of our widget event functions,
called by the SWT GUI system, runs in the context of that main
thread. So the main application thread is in charge of the GUI.
Another thread is the
FileIO thread
. When the main thread connects
to the target, it soon starts a separate thread that connects to the
target on a different port. This new thread becomes the target's file
server. The new thread reads input files from the disk and sends
audio/video data to the target, and receives data from the target and
writes output files.
The application also uses an occasional
timer thread
to update a
counter or periodically check for target status.
Creating a new thread in JavaScript is simple. For example, in code like
this, the main thread prints "Hello", then creates a secondary thread that
prints "cruel" when it runs, and finally the main thread prints "world".
print( "Hello" );
new java.lang.Thread( new java.lang.Runnable() {
run: function() {
print( "cruel" );
}
} ).start();
print( "world" );
Summary of Contents for TMS320DM6437
Page 1: ...TMS320DM6437 DVDP Getting Started Guide Literature Number SPRUEV6 July 2007 ...
Page 20: ...2 8 ...
Page 34: ...3 14 ...
Page 40: ...4 6 ...
Page 63: ......