Beispiel #1
0
void ConnectionInitEx(Task theAppTask, const msg_filter *msgFilter)
{
    theCm.msgFilter = msgFilter;

    /* Turn on extended bluestack prims */
    VmUseExtendedBluestackPrimitives();
    
    /* Initialise the Connection Library Task, all upstream messages sent by
       Bluestack will be handled by this task */
    theCm.task.handler = connectionBluestackHandler;
    
    /* If a task is already registered to receive BlueStack prims then we panic! */
    if (MessageBlueStackTask(connectionGetCmTask()))
    {
        CL_DEBUG(("ERROR - task already registered\n"));
    }

    /* Init the resource locks */
    initLocks();

    /* Store the application task */
    theCm.theAppTask = theAppTask;

    /* Start the initialisation process */
    MessageSend(connectionGetCmTask(), CL_INTERNAL_INIT_REQ, NO_PAYLOAD);
}
Beispiel #2
0
void Game::init() {
  if (initialized) {
    return;
  }
  initGlobals();
  initialized = true;
  
  // SDL
  if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
    Log::message(Log::Error, SDL_GetError());
    exit(0);
  }
  
  // TTF
  if (TTF_Init()) {
    Log::message(Log::Error, TTF_GetError());
    exit(0);
  }
  
  // SDLNet
  if (SDLNet_Init()) {
    Log::message(Log::Error, SDLNet_GetError());
    exit(0);
  }
  
  // OpenAL
  if (!initOpenAL()) {
    Log::message(Log::Error, alError);
    exit(0);
  }
  
  initLocks();
  
  Graphics::init();
  Audio::init();
}
Beispiel #3
0
int main(int argc, char *argv[]) {
   int i;
   int id[NUM_PHILOSOPHERS];
   pthread_t childid[NUM_PHILOSOPHERS];

   /* Seed random with time since epoch */ 
   srandom(time(0));

   /* Set the number of eat-think cycles */    
   if (argc > 1) {
      /* Non Default Cycles */ 
      numCycles = atoi(argv[1]);

      if (numCycles == 0) {
         /* Error with atoi or 0 */ 
         numCycles = DEFAULT_CYCLES;
      }
   }
   else {
      /* No command line argument, use default */ 
      numCycles = DEFAULT_CYCLES;
   }

   printHeader();

   initLocks();

   for (i = 0; i < NUM_PHILOSOPHERS; i++) {
      /* Initialize philosopher IDs */ 
      id[i] = i;	 

      /* Initialize printing array */ 
      printForks[i] = FORK_DOWN;

      /* Initialize philosopher states, they all start hungry */ 
      state[i] = CHANGING;
   }

   /* Spawn the philosophers */ 
   for (i = 0; i < NUM_PHILOSOPHERS; i++) {
      int res;
      res = pthread_create(
      	            &childid[i], 
                     NULL, 
                     philosopher, 
                     (void *) (&id[i]));

      if (res == -1) {
      	fprintf(stderr, "Error spawning child %i: %s\n", 
               i, strerror(errno));
      	exit(-1);
      }                       
   }

   /* Wait for all the philosophers */ 
   for (i = 0; i < NUM_PHILOSOPHERS; i++) {
      if (pthread_join(childid[i], NULL) != 0) {
         fprintf(stderr, "P thread error joining child \n");
         exit(-1);
      }
   }

   destroyLocks();

   printFooter();

   return 0;
}