• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Worker类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Worker的典型用法代码示例。如果您正苦于以下问题:C++ Worker类的具体用法?C++ Worker怎么用?C++ Worker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Worker类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: runnableTest

	void runnableTest()
	{
		Worker worker;
		Thread thread(&worker);

		thread.start();
		worker.start();

		CPPUNIT_ASSERT(worker.isQuit() == false);
		worker.quit();
		const unsigned int result = thread.join();
		CPPUNIT_ASSERT(result == 1);


		CPPUNIT_ASSERT(worker.isQuit() == true);
		worker.join();
	}
开发者ID:rayfill,项目名称:cpplib,代码行数:17,代码来源:ThreadTest.cpp


示例2: ACE_TMAIN

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

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

      Worker worker (orb.in ());

      if (worker.activate (THR_NEW_LWP | THR_JOINABLE,
                           nthreads) != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "(%P|%t) Cannot activate worker threads\n"),
                          1);

      int timeout = 30;
      int now = 0;
      while (now < timeout
        && ((expect_ex_kind != TAO::FOE_NON
             && worker.received_ex_kind () != expect_ex_kind
             && worker.num_received_ex () != expect_num_ex)
            || expect_ex_kind == TAO::FOE_NON))
      {
        std::cout << ".";
        now += 1;
        ACE_Time_Value tv (1, 0);
        orb->run (tv);
      }
      std::cout << std::endl;

      worker.done ();

      if (do_shutdown)
        {
          CORBA::Object_var object =
            orb->string_to_object (ior);

          Simple_Server_var server =
            Simple_Server::_narrow (object.in ());

          server->shutdown ();
        }

      ACE_OS::sleep (1);

      orb->destroy ();

      worker.thr_mgr ()->wait ();

      if (worker.received_ex_kind () != expect_ex_kind
        || worker.num_received_ex () != expect_num_ex)
      {
        ACE_ERROR_RETURN ((LM_ERROR,
          ("(%P|%t)client: test failed - expected is different from received. "
          "expected %d/%d received %d/%d.\n"),
          expect_ex_kind, expect_num_ex, worker.received_ex_kind (), worker.num_received_ex()),
                          1);
      }

      ACE_DEBUG ((LM_DEBUG, "(%P|%t)client: test passed.\n"));
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught in main:");
      return 1;
    }

  return 0;
}
开发者ID:milan-mpathix,项目名称:ATCD,代码行数:73,代码来源:client.cpp


示例3: switch

//
// Shows the selected item's disk starting sector, size, and queue depth.
//
void CPageDisk::ShowSettings()
{
	Manager *manager;
	Worker	*worker;
	int disk_size;
	int disk_start;
	int queue_depth;

	// Get the values for the disk settings from memory.
	switch ( theApp.pView->m_pWorkerView->GetSelectedType() )
	{
	case WORKER:
		worker = theApp.pView->m_pWorkerView->GetSelectedWorker();
		disk_size = worker->GetDiskSize( GenericDiskType );
		disk_start = worker->GetDiskStart( GenericDiskType );
		queue_depth = worker->GetQueueDepth( GenericDiskType );
		break;
	case MANAGER:
		manager = theApp.pView->m_pWorkerView->GetSelectedManager();
		disk_size = manager->GetDiskSize( GenericDiskType );
		disk_start = manager->GetDiskStart( GenericDiskType );
		queue_depth = manager->GetQueueDepth( GenericDiskType );
		break;
	default:
		disk_size = theApp.manager_list.GetDiskSize( GenericDiskType );
		disk_start = theApp.manager_list.GetDiskStart( GenericDiskType );
		queue_depth = theApp.manager_list.GetQueueDepth( GenericDiskType );
	}
	// If there is a displayable value, display it.  Otherwise, hide the content
	// of the edit box.
	if ( disk_size == AMBIGUOUS_VALUE )
	{
		m_EDiskSize.SetPasswordChar( 32 );
		m_EDiskSize.Invalidate();
	}
	else
	{
		m_EDiskSize.SetPasswordChar( 0 );
		SetDlgItemInt( EDiskSize, disk_size );
	}

	if ( disk_start == AMBIGUOUS_VALUE )
	{
		m_EDiskStart.SetPasswordChar( 32 );
		m_EDiskStart.Invalidate();
	}
	else
	{
		m_EDiskStart.SetPasswordChar( 0 );
		SetDlgItemInt( EDiskStart, disk_start );
	}
	
	if ( queue_depth == AMBIGUOUS_VALUE )
	{
		m_EQueueDepth.SetPasswordChar( 32 );
		m_EQueueDepth.Invalidate();
	}
	else
	{
		m_EQueueDepth.SetPasswordChar( 0 );
		SetDlgItemInt( EQueueDepth, queue_depth );
	}
}
开发者ID:BackupTheBerlios,项目名称:iometer-svn,代码行数:66,代码来源:PageDisk.cpp


示例4: ErrorMessage

//
// Stores the targets that have been selected by the user with the appropriate
// worker.
//
void CPageDisk::StoreTargetSelection()
{
	HTREEITEM hdisk;
	Manager *manager;
	Worker	*worker;
	int		target = 0;
	int		next_worker;
	
	// Get the selected manager and worker.
	manager = theApp.pView->m_pWorkerView->GetSelectedManager();
	worker = theApp.pView->m_pWorkerView->GetSelectedWorker();

	// Make sure we have a selected manager (or worker).
	if ( !manager )
	{
		ErrorMessage( "Unexpectedly found no selected manager in "
			"CPageDisk::StoreTargetSelection." );
		return;
	}

	if ( worker )
	{
		// Assign the targets to the selected worker in the order that they
		// appear in the GUI.
		worker->RemoveTargets( GenericDiskType );
		for ( hdisk = m_TTargets.GetRootItem(); hdisk; hdisk = 
			m_TTargets.GetNextSiblingItem( hdisk ) )
		{
			if ( GetSelectionCheck( hdisk ) == TargetChecked )
				worker->AddTarget( manager->GetInterface( target, GenericDiskType ) );
			target++;
		}
	}
	else
	{
		// Clear the assigned targets from all the manager's workers.
		manager->RemoveTargets( GenericDiskType );

		// Set the first worker to receive targets.
		worker = manager->GetWorker( 0, GenericDiskType );
		next_worker = 0;

		// Assign the targets to the workers of the selected manager.
		for ( hdisk = m_TTargets.GetRootItem(); hdisk; hdisk = 
			m_TTargets.GetNextSiblingItem( hdisk ) )
		{
			// If the disk is selected in the GUI, assign it to the expected
			// worker.
			if ( GetSelectionCheck( hdisk ) == TargetChecked )
			{
				worker->AddTarget( manager->GetInterface( target, GenericDiskType ));

				// Update who the next worker to receive a target is.
				if ( ++next_worker >= manager->WorkerCount( GenericDiskType ) )
					next_worker = 0;
				worker = manager->GetWorker( next_worker, GenericDiskType );
			}
			target++;
		}
	}
	ShowTargetSelection();
}
开发者ID:BackupTheBerlios,项目名称:iometer-svn,代码行数:66,代码来源:PageDisk.cpp


示例5: ACE_TMAIN

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  int priority =
    (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO)
     + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2;

  priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO,
                                              priority);

  priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO,
                                              priority);

  // Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
  if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
                                              priority,
                                              ACE_SCOPE_PROCESS)) != 0)
    {
      if (ACE_OS::last_error () == EPERM)
        {
          ACE_DEBUG ((LM_DEBUG,
                      "server (%P|%t): user is not superuser, "
                      "test runs in time-shared class\n"));
        }
      else
        ACE_ERROR ((LM_ERROR,
                    "server (%P|%t): sched_params failed\n"));
    }

  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      if (CORBA::is_nil (poa_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager ();

      poa_manager->activate ();

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

      CORBA::Object_var progress_object =
        orb->string_to_object (ior);

      Progress_var progress =
        Progress::_narrow (progress_object.in ());

      ACE_Time_Value delay (0, interval);

      Peer_i peer;
      peer.init (orb.in (),
                 progress.in (),
                 delay);

      Worker worker (orb.in ());
      if (worker.activate (THR_NEW_LWP | THR_JOINABLE,
                           nthreads) != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot activate client threads\n"),
                          1);

      worker.thr_mgr ()->wait ();

      ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Caught exception:");
      return 1;
    }

  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:85,代码来源:peer.cpp


示例6: dispatch

void* Worker::dispatch(void *arg) {
    Worker *worker = (Worker *) arg;
    worker->handleTasks();
    //delete worker;
    return 0;
}
开发者ID:anantoni,项目名称:tcp-client-server,代码行数:6,代码来源:worker.cpp


示例7: Worker

Worker* PeopleGenerator::GenerateWorker()
{
	std::string spriteName = "Worker";
	Worker* result = new Worker();
	result->Speed = 1.5f;
	result->Happiness = 0.5f;
	result->Age = 30;
	if (rand() % 2)
	{
		result->PersonGender = Person::Gender::Male;
		spriteName += "_Male";

		int blarand = rand() % 7;

		if (blarand == 0)
		{
			spriteName += "_Asian";
			result->CleaningOffsets[0] = sf::Vector2f(153, 38);
			result->CleaningOffsets[1] = sf::Vector2f(-163, 48);
			result->CleaningOffsets[2] = sf::Vector2f(-49, -86);
			result->CleaningOffsets[3] = sf::Vector2f(33, -87);
		}
		if (blarand == 1)
		{
			spriteName += "_Black";
			result->CleaningOffsets[0] = sf::Vector2f(230, -40);
			result->CleaningOffsets[1] = sf::Vector2f(-246, -30);
			result->CleaningOffsets[2] = sf::Vector2f(-110, -243);
			result->CleaningOffsets[3] = sf::Vector2f(23, -243);
		}
		if (blarand == 2)
		{
			spriteName += "_Grandpa";
		}
		if (blarand == 3)
		{
			spriteName += "_Indian";
			result->CleaningOffsets[0] = sf::Vector2f(39, 40);
			result->CleaningOffsets[1] = sf::Vector2f(-54, 50);
			result->CleaningOffsets[2] = sf::Vector2f(-63, -40);
			result->CleaningOffsets[3] = sf::Vector2f(0, -41);
		}
		if (blarand == 4)
		{
			spriteName += "_Intern";
		}
		if (blarand == 5)
		{
			spriteName += "_Mexican";
			result->CleaningOffsets[0] = sf::Vector2f(111, 39);
			result->CleaningOffsets[1] = sf::Vector2f(-126, 49);
			result->CleaningOffsets[2] = sf::Vector2f(-16, -47);
			result->CleaningOffsets[3] = sf::Vector2f(3, -46);
		}
		if (blarand == 6)
		{
			spriteName += "_Russian";
		}
	}
	else
	{
		result->PersonGender = Person::Gender::Female;
		spriteName += "_Female";

		int blarand = rand() % 2;

		if (blarand == 0)
		{
			spriteName += "_Bitch";
		}
		if (blarand == 1)
		{
			spriteName += "_Intern";
			result->CleaningOffsets[0] = sf::Vector2f(16, -90);
			result->CleaningOffsets[1] = sf::Vector2f(-2, -80);
			result->CleaningOffsets[2] = sf::Vector2f(-40, -143);
			result->CleaningOffsets[3] = sf::Vector2f(73, -161);
		}
	}

	std::wstring name = L"";
	if (result->PersonGender == Person::Gender::Male)
	{
		name += this->FirstNamesMale[rand() % this->FirstNamesMale.size()] + L" ";
	}
	else
	{
		name += this->FirstNamesFemale[rand() % this->FirstNamesFemale.size()] + L" ";
	}
	if (rand() % 100 < 5)
	{
		if (result->PersonGender == Person::Gender::Male)
		{
			name += this->FirstNamesMale[rand() % this->FirstNamesMale.size()] + L" ";
		}
		else
		{
			name += this->FirstNamesFemale[rand() % this->FirstNamesFemale.size()] + L" ";
		}

//.........这里部分代码省略.........
开发者ID:DoktorNebel,项目名称:Portfolio,代码行数:101,代码来源:PeopleGenerator.cpp


示例8: main

 int Worker::main(void* _worker)
 {
   Worker* worker = static_cast<Worker*>(_worker);
   worker->loop();
   return 0;
 }
开发者ID:deek0146,项目名称:framework2d,代码行数:6,代码来源:Worker.cpp


示例9: main

int main(int argc, char const *argv[]) {
    Worker john;
    john.greeting();
    exiter();
    return 0;
}
开发者ID:JesterofDoom13,项目名称:CPP,代码行数:6,代码来源:main.cpp


示例10: Worker

void
Controller::restore(QString filename)
{
    Worker *worker = new Worker(this, Controller::RESTORE, filename);
    worker->start();
}
开发者ID:harmattan,项目名称:MeegoSMSBackupRestore,代码行数:6,代码来源:gui.cpp


示例11: Tbb_Folder

 Tbb_Folder(Worker & w)
 :w_(w)
 {
     out_ = w.neutral_(nt2::meta::as_<result_type>());
 }
开发者ID:aminiussi,项目名称:nt2,代码行数:5,代码来源:fold.hpp


示例12:

static void *worker_run(void *arg)
{
    Worker *worker = (Worker *)arg;
    worker->run();
    return NULL;
}
开发者ID:zilongwhu,项目名称:ls-server,代码行数:6,代码来源:worker.cpp


示例13: ACE_TMAIN

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

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

      Worker worker (orb.in ());

      if (worker.activate (THR_NEW_LWP | THR_JOINABLE,
                           nthreads) != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "(%P|%t) Cannot activate worker threads\n"),
                          1);

      int timeout = 30;
      int now = 0;
      while (now < timeout &&
             ((expect_ex_kind == 0 && !worker.invocation_completed ()) ||
              (expect_ex_kind != 0 && expect_ex_kind != worker.received_ex_kind ()))
             )
        {
          std::cout << "." << std::flush;
          now += 1;
          ACE_Time_Value tv (1, 0);
          orb->run (tv);
        }
      ACE_ASSERT (now != 0);


      std::cout << std::endl;

      worker.done ();

      CORBA::Object_var object =
        orb->string_to_object (ior);

      Simple_Server_var server =
        Simple_Server::_narrow (object.in ());

      server->shutdown ();

      ACE_OS::sleep (1);

      orb->destroy ();

      worker.thr_mgr ()->wait ();


      bool expect_no_ex =
        expect_ex_kind == TAO::FOE_NON && worker.num_received_ex () == 0 && worker.invocation_completed ();
      bool expect_ex_received =
        expect_ex_kind == worker.received_ex_kind () && worker.num_received_ex () > 0 && !worker.invocation_completed ();
      if (expect_no_ex || expect_ex_received)
        {
          ACE_DEBUG ((LM_DEBUG, "(%P|%t)client: test passed.\n"));
          return 0;
        }
      else
        {
          ACE_DEBUG ((LM_ERROR, "(%P|%t)client: test failed.\n"));
          return 1;
        }
    }

  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught in main:");
      return 1;
    }

  return 0;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:77,代码来源:client.cpp


示例14: main

int main(int argc, char** argv){
    MPI_Init(&argc, &argv);
    Worker worker;
    worker.run();
    MPI_Finalize();
}
开发者ID:vmlaker,项目名称:hello-cpp,代码行数:6,代码来源:mpi02.C


示例15: log_debug

  void TntnetImpl::run()
  {
    log_debug("worker-process");

    _stop = false;

    if (_listeners.empty())
      throwRuntimeError("no listeners defined");

    log_debug(_listeners.size() << " listeners");

    if (_listeners.size() >= _minthreads)
    {
      log_warn("at least one more worker than listeners needed - set MinThreads to "
        << _listeners.size() + 1);
      _minthreads = _listeners.size() + 1;
    }

    if (_maxthreads < _minthreads)
    {
      log_warn("MaxThreads < MinThreads - set MaxThreads = MinThreads = " << _minthreads);
      _maxthreads = _minthreads;
    }

    // initialize worker-process

    // SIGPIPE must be ignored
    ::signal(SIGPIPE, SIG_IGN);

    // create worker-threads
    log_info("create " << _minthreads << " worker threads");
    for (unsigned i = 0; i < _minthreads; ++i)
    {
      log_debug("create worker " << i);
      Worker* s = new Worker(*this);
      s->create();
    }

    // create poller-thread
    log_debug("start poller thread");
    _pollerthread.start();

    log_debug("start timer thread");
    cxxtools::AttachedThread timerThread(cxxtools::callable(*this, &TntnetImpl::timerTask));
    timerThread.start();

    {
      cxxtools::MutexLock lock(allTntnetInstancesMutex);
      allRunningTntnetInstances.insert(this);
    }

    // mainloop
    cxxtools::Mutex mutex;
    while (!_stop)
    {
      {
        cxxtools::MutexLock lock(mutex);
        _queue.noWaitThreads.wait(lock);
      }

      if (_stop)
        break;

      if (Worker::getCountThreads() < _maxthreads)
      {
        log_info("create workerthread");
        Worker* s = new Worker(*this);
        s->create();
      }
      else
        log_info("max worker-threadcount " << _maxthreads << " reached");

      if (TntConfig::it().threadStartDelay > 0)
        usleep(TntConfig::it().threadStartDelay.totalUSecs());
    }

    log_info("stopping TntnetImpl");

    {
      cxxtools::MutexLock lock(allTntnetInstancesMutex);
      allRunningTntnetInstances.erase(this);
    }

    log_info("stop listener");
    for (listeners_type::iterator it = _listeners.begin(); it != _listeners.end(); ++it)
      (*it)->terminate();

    log_info("stop poller thread");
    _poller.doStop();
    _pollerthread.join();

    log_info("stop timer thread");
    timerThread.join();

    if (Worker::getCountThreads() > 0)
    {
      log_info("wait for " << Worker::getCountThreads() << " worker threads to stop");
      while (Worker::getCountThreads() > 0)
      {
        log_debug("wait for worker threads to stop; " << Worker::getCountThreads() << " left");
//.........这里部分代码省略.........
开发者ID:maekitalo,项目名称:tntnet,代码行数:101,代码来源:tntnetimpl.cpp


示例16: main

int main(int argc, char* argv[]){
    Worker wk;
    wk.Start();
    return 0;
}
开发者ID:bonly,项目名称:exercise,代码行数:5,代码来源:20110514_obj.cpp


示例17: svc

int Query_Processor::svc()
{
	Worker * worker;
	int ret,cached;
	//ScribeProxyClient *client=NULL;
	std::vector<std::string> category;
	int queueLen = 0;
	cerr<<"initialized thread..."<<endl;

	pthread_barrier_wait(processor_init);

	while ((worker = m_task_list.get()) != NULL)
	{
		queueLen = m_task_list.len();

		ret = parse_worker(worker);
		if(ret >= 0)
		{
			// TODO: process the request and fill the result in result
			//snprintf(result, MAX_HTTP_CONTENT_LENGTH, "<h1>Hello world!</h1>Query string: %s", worker->querystring);
			ret = 0;
			//clock_t start=clock();

			//Chat Server 
			string szOrigInput = worker->querystring;

			string res = "";
            //usleep(300000);

			if(szOrigInput == "register_slave")
			{
				std::string server_ip = get_param("server_ip=", worker->uri);
				std::string recv_realtime_req_str = get_param("recv_real_time_request=", worker->uri);
				bool recv_realtime_req = (recv_realtime_req_str == "True")?true:false;
				m_validation->registerSlave(server_ip, recv_realtime_req);
			}
			else if(szOrigInput == "validate")
			{
                string req = get_param("req", worker->uri);
                string type = get_param("type", worker->uri);
                m_validation->handleValidReq(req, type, res);
			}


			// copy the result into worker
			int max_len = 65536000;
			worker->result = (char*)worker->GetMem(max_len);
			if (worker->result == NULL)
			{
				pthread_mutex_unlock(&gMutex);//解锁
				m_httpserver->retrieve_worker(worker);
				continue;
			}
			if("" != res)
			{
				//int max_len = MAX_HTTP_CONTENT_LENGTH;
				worker->result_len = std::min(res.length(), size_t(max_len) - 1) + 1;
				memcpy(worker->result, res.c_str(), worker->result_len);
				worker->result[worker->result_len] = 0;
				_INFO("[ Result: %s]", worker->result);
			}

			//pthread_mutex_unlock(&gMutex);//解锁
		}//if

		int retlen = (ret==-1)?-1:worker->result_len;
		const char * queryStr = (worker->query_len<=0)?"NULL":worker->querystring;
		_INFO("[Observer,cost=%d,ret=%d,querystring=%s,Owner=OP]",WASTE_TIME_US(worker->receive_time),retlen,queryStr);

		m_httpserver->retrieve_worker(worker);
	}//while

	cerr<<"closed thread!!"<<endl;

	return 0;
}
开发者ID:dangpu,项目名称:momoko,代码行数:76,代码来源:query_processor.cpp


示例18: ACE_TMAIN


//.........这里部分代码省略.........
          CORBA::Object_var manager_obj =
            orb->resolve_initial_references ("RTSchedulerManager");

          TAO_RTScheduler_Manager_var manager =
            TAO_RTScheduler_Manager::_narrow (manager_obj.in ());

          Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type;
          if (enable_yield)
            {
              disp_impl_type = Kokyu::DSRT_CV_BASED;
            }
          else
            {
              disp_impl_type = Kokyu::DSRT_OS_BASED;
            }

          ACE_NEW_RETURN (scheduler,
                          Fixed_Priority_Scheduler (orb.in (),
                                         disp_impl_type,
                                         sched_policy,
                                         sched_scope), -1);
          sched_owner = scheduler;

          manager->rtscheduler (scheduler);

          CORBA::Object_var object =
            orb->resolve_initial_references ("RTScheduler_Current");

          current  =
            RTScheduling::Current::_narrow (object.in ());
        }

      Simple_Server_i server_impl (orb.in (),
                                   current.in (),
                                   task_stats,
                                   enable_yield);

      Simple_Server_var server =
        server_impl._this ();

      CORBA::String_var ior =
        orb->object_to_string (server.in ());

      ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.in ()));

      // If the ior_output_file exists, output the ior to it
      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", ior.in ());
          ACE_OS::fclose (output_file);
        }

      poa_manager->activate ();

      Worker worker (orb.in ());
      if (worker.activate (flags,
                           nthreads,
                           0,
                           ACE_Sched_Params::priority_max(sched_policy,
                                                          sched_scope)) != 0)
        {
          ACE_ERROR ((LM_ERROR,
                      "Cannot activate threads in RT class.",
                      "Trying to activate in non-RT class\n"));

          flags = THR_NEW_LWP | THR_JOINABLE | THR_BOUND;
          if (worker.activate (flags, nthreads) != 0)
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 "Cannot activate server threads\n"),
                                1);
            }
        }

      worker.wait ();

      ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));

      ACE_DEBUG ((LM_DEBUG, "shutting down scheduler\n"));
      scheduler->shutdown ();

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  ACE_DEBUG ((LM_DEBUG, "Exiting main...\n"));
  task_stats.dump_samples (ACE_TEXT("timeline.txt"),
                           ACE_TEXT("Time\t\tGUID"));
  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:101,代码来源:server.cpp


示例19: ACE_TMAIN

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references ("RootPOA");

      if (CORBA::is_nil (poa_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager ();

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

      Simple_Server_i *server_impl = 0;
      ACE_NEW_RETURN (server_impl,
                      Simple_Server_i (orb.in ()),
                      -1);

      PortableServer::ServantBase_var owner_transfer(server_impl);

      PortableServer::ObjectId_var id =
        root_poa->activate_object (server_impl);

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

      Simple_Server_var server =
        Simple_Server::_narrow (object.in ());

      CORBA::String_var ior =
        orb->object_to_string (server.in ());

      ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.in ()));

      // If the ior_output_file exists, output the ior to it
      if (ior_output_file != 0)
        {
          FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
          if (output_file == 0)
            ACE_ERROR_RETURN ((LM_ERROR,
                               "(%P|%t) Cannot open output file for writing IOR: %s",
                               ior_output_file),
                              1);
          ACE_OS::fprintf (output_file, "%s", ior.in ());
          ACE_OS::fclose (output_file);
        }

      poa_manager->activate ();

      Worker worker (orb.in ());
      if (worker.activate (THR_NEW_LWP | THR_JOINABLE,
                           nthreads) != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "(%P|%t) Cannot activate client threads\n"),
                          1);

      SelfClient selfabuse (orb.in(), server.in(), niterations);
      if (selfabuse.activate (THR_NEW_LWP | THR_JOINABLE,
                              nclient_threads) != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "(%P|%t) Cannot activate abusive threads\n"),
                          1);

      selfabuse.thr_mgr()->wait();

      worker.thr_mgr ()->wait ();

      ACE_DEBUG ((LM_DEBUG,
                  "(%P|%t) event loop finished\n"));
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:89,代码来源:server.cpp


示例20: handleConnection

int handleConnection(ClientSocket* socket)
{
    Worker* worker = new Worker(socket);
    worker->run();
    return 0;
}
开发者ID:msramos,项目名称:mighttpd,代码行数:6,代码来源:main.cpp



注:本文中的Worker类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WorkerContext类代码示例发布时间:2022-05-31
下一篇:
C++ Workbench类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap