Exemple #1
0
void os_exit_task() {
    BIT_CLEAR(tasks[cur_task].flags, TASK_FLAG_RUNNING);
    BIT_SET(tasks[cur_task].flags, TASK_FLAG_DONE);
    cur_task = -1;

    do_something_else();
}
Exemple #2
0
static void
do_select_curl(char ** connections) {

	SelectCurler * curler = new SelectCurler();
	curler->addConnections(connections);

	int max_loop = 100;
	int done = 0;
	do {
		do_something_else();

		fd_set read_fd_set;
		FD_ZERO(&read_fd_set);

		fd_set write_fd_set;
		FD_ZERO(&write_fd_set);

		fd_set exc_fd_set;
		FD_ZERO(&exc_fd_set);
		done = curler->doSelect(&read_fd_set, &write_fd_set, &exc_fd_set);

	} while (max_loop -- > 0 && !done);
	delete(curler);
	trace_info("EXITING  done_with_all_connections = %d\n", done);
}
/*-------------------------------------------------------*/
PROCESS_THREAD(example_process, ev, data)
{
	PROCESS_BEGIN();
		do_something();
		PROCESS_PAUSE();
		do_something_else();
		PROCESS_WAIT_UNTIL(temperatur > 30);
		do_something_completely_else();
	PROCESS_END();
}
int process_xyz(int marke)
{
	int i = 0;
	switch(marke)
	{
	case 0:
		do_something();
		return 123;
	case 123:
		do_something_else();
		return PROCESS_DONE;
	}
}
int main(int argc, char *argv[]) {
   volatile int a = 5;
   {
      volatile int a = 14;
      const int SOME_FAKE_VAL = 302;
      int* apple = new int[a];
      apple = new int[a];
   }
   const int COUNT = 12;
   const int INT_ARRAY = 20;
   SomeStruct* structArray = new SomeStruct[COUNT];
   int* array = new int[INT_ARRAY];
   int* array2 = new int[INT_ARRAY];
   int* array4 = new int;
   std::string catParty = "hello world!";
   std::vector<int> myVector = { 6, 2, 3, 7, 5, 4, 1 };
   int quantity = 32;
   for (int i = 0; i < quantity; ++i) {
      myVector.push_back(i);
   }
   for (int i = 0; i < quantity; ++i) {
      really_stupid_waste();
   }
   for(int i = 0; i < COUNT; ++i) {
      structArray[i].a = 2;
      structArray[i].b = 4;
      structArray[i].c = 13;
   }
   for(int i = 0; i < INT_ARRAY; ++i) {
      array[i] = 14;
      array2[i] = 14;
   }
   int* array3 = new int[INT_ARRAY];
   int q = do_something(array[0]);
   int total = do_something_else(array, INT_ARRAY);
   delete array4;
   array4 = dynamic_copy(array, INT_ARRAY);
   unsigned long someFact = fact(6);
   unsigned long someFib = fib(8);
   for (auto& i : myVector) {
      std::cout << i << std::endl;
   }
   while( ! myVector.empty() ) {
      myVector.pop_back();
   }
   std::cout << catParty << std::endl;
   return 0;
}
void test()
{
    switch (x) {
        case 0:
        case 1:
            do_something();
            break;
        case 2:
            do_something_else();
            break;
        default:
            break;
    }

    if (condition) x++;

    if (x == y) {
        q();
    } else if (x > y) {
        w();
    } else {
        r();
    }

    function_one();  // this is function 1
    func();          // another function
    func_two();      // function two

    this_is_a_really_long_function(argument_one,
                                   argument_two,
                                   argument_three,
                                   argument_four,
                                   argument_five);

    double squareness =
        num_nets * -1.62428552015961E-4 +
        1.0 / (grid_h * grid_h) * num_cells * 3.02812966834494E-1 +
        2.41123889653172 / grid_h + pow(6.19504321450544E-1, grid_w) * grid_h -
        pow(6.19504321450544E-1, grid_w) * num_cells * 3.02812966834494E-1 +
        3.41290981390719E-1;
}
Exemple #7
0
void os_sleep(uint16_t millis) {
    tasks[cur_task].delayMillis = millis;
    do_something_else();
}
Exemple #8
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      // Initialize orb
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      if (parse_args (argc, argv) != 0)
        {
          return 1;
        }

      // Get reference to Root POA.
      CORBA::Object_var obj
        = orb->resolve_initial_references ("RootPOA");

      PortableServer::POA_var poa
        = PortableServer::POA::_narrow (obj.in ());

      // Activate POA manager.
      PortableServer::POAManager_var mgr
        = poa->the_POAManager ();

      mgr->activate ();

      // Create an object.
      Time_impl time_servant;

      // Write its stringified reference to stdout.
      PortableServer::ObjectId_var id =
        poa->activate_object (&time_servant);

      CORBA::Object_var object = poa->id_to_reference (id.in ());

      Time_var tm = Time::_narrow (object.in ());

      CORBA::String_var str = orb->object_to_string (tm.in ());

      ACE_DEBUG ((LM_DEBUG,
                  "%s\n",
                  str.in ()));

      if (ior_output_file != 0)
        {
          FILE *output_file= ACE_OS::fopen (ior_output_file, "w");

          if (output_file == 0)
            {
              ACE_ERROR_RETURN ((
                  LM_ERROR,
                  "Cannot open output file for writing IOR: %s",
                  ior_output_file
                ),
                1
              );
            }

          ACE_OS::fprintf (output_file,
                           "%s",
                           str.in ());
          ACE_OS::fclose (output_file);
        }

      // Explicit Event Loop.
      while (!done)
        {
          CORBA::Boolean pending =
            orb->work_pending ();

          if (pending)
            {
              orb->perform_work ();
            }
          do_something_else ();
        }

      orb->shutdown ();
      orb->destroy ();
    }

  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("server: a CORBA exception occured");
      return 1;
    }
  catch (...)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "%s\n",
                         "client: an unknown exception was caught\n"),
                         1);
    }

  return 0;
}