示例#1
0
void *
GThread::start(void *arg)
{
  GThread *gt = (GThread*)arg;
#ifdef DCETHREADS
#ifdef CANCEL_ON
  pthread_setcancel(CANCEL_ON);
  pthread_setasynccancel(CANCEL_ON);
#endif
#else // !DCETHREADS
#ifdef PTHREAD_CANCEL_ENABLE
  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0);
#endif
#ifdef PTHREAD_CANCEL_ASYNCHRONOUS
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
#endif
#endif
  // Catch exceptions
#ifdef __EXCEPTIONS
  try 
    {
#endif 
      G_TRY
        {
          (gt->xentry)(gt->xarg);
        }
      G_CATCH(ex)
        {
          ex.perror();
          DjVuMessageLite::perror( ERR_MSG("GThreads.uncaught") );
#ifdef _DEBUG
          abort();
#endif
        }
      G_ENDCATCH;
#ifdef __EXCEPTIONS
    }
  catch(...)
    {
          DjVuMessageLite::perror( ERR_MSG("GThreads.unrecognized") );
#ifdef _DEBUG
      abort();
#endif
    }
#endif
  return 0;
}
示例#2
0
int main()
{

	pthread_setcancel(CANCEL_ON);

	printf ("test3:         raising a cancel in a TRY block\n");
	EXCEPTION_INIT(e1);
	TRY
	{
		TRY
		{
			printf (" in inner try block. Cancelling myself. \n");


			pthread_cancel(pthread_self());
			printf("\t... called pthread_cancel(). calling testcancel\n");
			pthread_testcancel();
		}
		CATCH(e1)
		{
			printf("\t... in handler for e1. \n");
		}
		CATCH(pthread_cancel_e)
		{
			printf ("\t... in pthread_cancel_e inner handler\n");
			printf ("exception report: \n");
			exc_report(_exc_cur);
			RERAISE;
		}
		ENDTRY
	}
	CATCH(e1)
	{
		printf("\t... in outer handler for e1.");
	}
	CATCH(pthread_cancel_e)
	{
		printf("\t... in outer handler for pthread_cancel_e\n");
		printf ("exception report: \n");
		exc_report(_exc_cur);

	}
	ENDTRY;

	printf("normal exiting. \n");
	return 0;
}