Exemple #1
0
int Kbd(nTask receiver)
{
  char ch;

  nSetTaskName("lector");

  do
  {
    ch=GetchTty();
    nSend(receiver, &ch);
  }
    while (ch!='q');
}
Foam::autoPtr<Foam::mapDistribute> Foam::backgroundMeshDecomposition::buildMap
(
    const List<label>& toProc
)
{
    // Determine send map
    // ~~~~~~~~~~~~~~~~~~

    // 1. Count
    labelList nSend(Pstream::nProcs(), 0);

    forAll(toProc, i)
    {
        label procI = toProc[i];

        nSend[procI]++;
    }
Foam::autoPtr<Foam::mapDistribute>
Foam::DistributedDelaunayMesh<Triangulation>::buildMap
(
    const List<label>& toProc
)
{
    // Determine send map
    // ~~~~~~~~~~~~~~~~~~

    // 1. Count
    labelList nSend(Pstream::nProcs(), 0);

    forAll(toProc, i)
    {
        label procI = toProc[i];

        nSend[procI]++;
    }
Exemple #4
0
nMain(int argc, char **argv)
{
  nSetTimeSlice(2);

  InitTty();
  ClearTty();

  PrintTty(6,2, " B O U N C E");
  PrintTty(7,2, "   G A M E  ");
  PrintTty(10,2,"j: izquierda");
  PrintTty(11,2,"k: derecha");
  PrintTty(13,2,"espacio: fuego");
  PrintTty(15,2,"q: fin");
  PrintTty(20,2,"bolas: 1");

  MINX= 1+strlen("espacio: fuego")+18;
  MINY= 1;
  MAXX= COLS-1;
  MAXY= LINES-1;

  { int i, j;
    for (j= MINY; j<=MAXY; j++)
    {
      PrintTty(j, MINX-1, "H");
      PrintTty(j, MAXX+1, "H");
      for (i= MINX; i<=MAXX; i++) screen[j][i]= ' ';
  } }

  RefreshTty();

  ACCY  = argc>=4 ? atoi(argv[3]) : 60.0;

  {
    int ivx= argc>=2 ? atoi(argv[1]) : 30;
    int ivy= argc>=3 ? atoi(argv[2]) : 40;
    int ix = argc>=5 ? atoi(argv[4]) : MINX;
    int iy = argc>=6 ? atoi(argv[5]) : MAXY;
    int Ball();

    ball_tasks[0]= nEmitTask(Ball, ix, iy, ivx, ivy);
  }

  {
    int Kbd(), Shot();
    nTask kbd_task= nEmitTask(Kbd, nCurrentTask());
    nTask shot_task= nEmitTask(Shot);
    int xpos= (MINX+MAXX+1)/2;
    char ch;

    while(!quit)
    {
      PrintTty(MAXY, xpos, "$");
      RefreshTty();
      ch= *(char*) nReceive(NULL, -1);
      nReply(kbd_task, 0);
      PrintTty(MAXY, xpos, " ");
      if (ch=='j')
      {
        screen[MAXY][xpos]= ' ';
        if (xpos>MINX+4) xpos-=4;
        screen[MAXY][xpos]= '$';
      }
      else if (ch=='k')
      {
        screen[MAXY][xpos]= ' ';
        if (xpos<MAXX-4) xpos+=4;
        screen[MAXY][xpos]= '$';
      }
      else if (ch==' ') { nSend(shot_task, &xpos); }
      else if (ch=='q') { kbd_task= NULL; break; }
    }

    if (kbd_task!=NULL)
    {
      do
      {
        ch= *(char*)nReceive(NULL, -1);
        nReply(kbd_task, 0);
      } while (ch!='q');
    }

    xpos= 0;
    nSend(shot_task, &xpos);
  }

  while (ball_count-->0)
  { /* se envia cualquier cosa no nula */
    nSend(ball_tasks[ball_count], (void*)&ball_count);
    nWaitTask(ball_tasks[ball_count]);
  }

  EndTty();
}