Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/QNX4/MsgThread2.cpp

Go to the documentation of this file.
00001 // Runs the message loop and dispatches to the proper child function.
00002 void MsgThread::Run()
00003 {
00004    char*  buf = new char[ MSG_BUFFER_MAX ];
00005    void*  feedback;
00006    pid_t  rpid;
00007    int    runme = 1;
00008 
00009    while ( runme ) {
00010 
00011       printf("\nReceive-Blocked,");
00012       rpid = Receive( 0, buf, sizeof(buf) );
00013       printf("\tMessage Received [%d],", rpid );
00014 
00015           if (  rpid > 0  ) 
00016       {
00017 
00018         if ( *((int*)buf) == MSG_KILL_THREAD ) {
00019          printf("\nMsgThread.cc: MSG_KILL_THREAD as *((int*)buf received,");
00020          runme = 0;
00021         } else {
00022          // Dispatch message into the children array of local function
00023          printf("\tLaunch Dispatcher,");
00024          feedback = MsgDispatcher( buf, rpid );
00025 
00026          printf("\tReply,");
00027             Reply( rpid, feedback, sizeof(feedback) );
00028          }
00029         printf("!");
00030       }  
00031         printf("!");
00032    }
00033    printf("\tBreak,");
00034 // Line 26
00035     // Send confirmation for destruction
00036    delete [] buf;
00037 
00038    printf( "\tReply NULL,");
00039     Reply( rpid, NULL, 0 );
00040 }
00041 
00042 // Stops the current thread (if running)
00043 void MsgThread::Stop()
00044 {
00045    printf("\nEntering MsgThread Stop,");
00046    int Kill_Msg = MSG_KILL_THREAD;
00047 
00048     if ( pid < 0 ) { return; }
00049 
00050     // Try to send  MSG_KILL_THREAD  message...
00051    printf("\tTry to send  MSG_KILL_THREAD  message...,");
00052     Send( pid, &Kill_Msg, NULL, sizeof( Kill_Msg ), 0 );
00053 
00054    printf("End Thread");
00055     _endthread();
00056 
00057     pid = -1;
00058 }

Generated on Sun Oct 14 18:46:42 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001