当前位置: 首页>>代码示例>>C++>>正文


C++ Host类代码示例

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


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

示例1: servePendingRequests

void Loader::servePendingRequests(Priority minimumPriority)
{
    if (m_isSuspendingPendingRequests)
        return;

    m_requestTimer.stop();
    
    m_nonHTTPProtocolHost->servePendingRequests(minimumPriority);

    Vector<Host*> hostsToServe;
    m_hosts.checkConsistency();
    HostMap::iterator i = m_hosts.begin();
    HostMap::iterator end = m_hosts.end();
    for (;i != end; ++i)
        hostsToServe.append(i->second.get());
        
    for (unsigned n = 0; n < hostsToServe.size(); ++n) {
        Host* host = hostsToServe[n];
        if (host->hasRequests())
            host->servePendingRequests(minimumPriority);
        else if (!host->processingResource()){
            AtomicString name = host->name();
            m_hosts.remove(name.impl());
        }
    }
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:26,代码来源:loader.cpp

示例2: Restart

void AppBinding::Restart(const ValueList& args, KValueRef result)
{
	Host* host = Host::GetInstance();
	std::wstring cmdline(::UTF8ToWide(host->GetApplication()->GetExecutablePath()));

	STARTUPINFO si;
	ZeroMemory(&si, sizeof(si));
	si.cb = sizeof(si);
	PROCESS_INFORMATION pi;
	ZeroMemory(&pi, sizeof(pi));

	::CreateProcessW(NULL,
		(LPWSTR) cmdline.c_str(),
		NULL, /*lpProcessAttributes*/
		NULL, /*lpThreadAttributes*/
		FALSE, /*bInheritHandles*/
		NORMAL_PRIORITY_CLASS,
		NULL,
		NULL,
		&si,
		&pi);
	CloseHandle(pi.hProcess);
	CloseHandle(pi.hThread);

	host->Exit(0);
}
开发者ID:directi,项目名称:titanium_desktop,代码行数:26,代码来源:win32_app_binding.cpp

示例3: ListenSocketCG

void ServerApp::Initialize() {
    ::printf("GatewayServer start.\n");

    Network::Startup();

    m_serverConfigManager.Initialize();

    m_networkService.Initialize(1024, 8);

    const auto& gatewayConfig = m_serverConfigManager.GetGatewayConfig();

    Host hostCG;
    hostCG.FromAddress(gatewayConfig.m_publicAddress);

    ListenSocketCG* listenSocketCG = new ListenSocketCG();
    listenSocketCG->Retain();
    listenSocketCG->SetLocalHost(hostCG);
    listenSocketCG->Listen(100);
    m_networkService.Manage(listenSocketCG);

    Host hostWG;
    hostWG.FromAddress(gatewayConfig.m_privateAddress);

    ListenSocketWG* listenSocketWG = new ListenSocketWG();
    listenSocketWG->Retain();
    listenSocketWG->SetLocalHost(hostWG);
    listenSocketWG->Listen(100);
    m_networkService.Manage(listenSocketWG);
}
开发者ID:Metazion,项目名称:MetazionWorld,代码行数:29,代码来源:ServerApp.cpp

示例4: log_debug

void Master::schedule_tasks() {
    log_debug("Scheduling %d tasks on %d slots...", 
        ready_queue.size(), free_slots.size());

    int scheduled = 0;
    TaskList deferred_tasks;

    while (ready_queue.size() > 0 && free_slots.size() > 0) {
        Task *task = ready_queue.top();
        ready_queue.pop();

        log_trace("Scheduling task %s", task->name.c_str());

        bool match = false;

        for (SlotList::iterator s = free_slots.begin(); s != free_slots.end(); s++) {
            Slot *slot = *s;
            Host *host = slot->host;

            // If the task fits, schedule it
            if (host->can_run(task)) {

                log_trace("Matched task %s to slot %d on host %s", 
                    task->name.c_str(), slot->rank, host->name());

                // Reserve the resources
                vector<cpu_t> bindings = host->allocate_resources(task);
                host->log_resources(resource_log);

                submit_task(task, slot->rank, bindings);

                s = free_slots.erase(s);

                // so that the s++ in the loop doesn't skip one
                s--;

                match = true;
                scheduled += 1;

                // This is to break out of the slot loop so that we can 
                // consider the next task
                break;
            }
        }

        if (!match) {
            // If the task could not be scheduled, then we save it 
            // and move on to the next one. It will be requeued later.
            log_trace("No slot found for task %s", task->name.c_str());
            deferred_tasks.push_back(task);
        }
    }

    log_debug("Scheduled %d tasks and deferred %d tasks", scheduled, deferred_tasks.size());

    // Requeue all the deferred tasks
    for (TaskList::iterator t = deferred_tasks.begin(); t != deferred_tasks.end(); t++) {
        ready_queue.push(*t);
    }
}
开发者ID:pegasus-isi,项目名称:pegasus,代码行数:60,代码来源:master.cpp

示例5: Host

Host Host::autoRegister()
{
	Host newHost = Host();
	newHost.setName(Host::currentHostName());
	newHost.setOnline(1);
	newHost.commit();

	newHost.updateHardwareInfo();

	Service ab = Service::recordByName("Assburner");
	if( ab.isRecord() ) {
		HostService hs = HostService();
		hs.setHost(newHost);
		hs.setService(ab);
		hs.commit();
	}

	HostGroup hg = HostGroup::recordByName("All");
	if( hg.isRecord() ) {
		HostGroupItem hgi = HostGroupItem();
		hgi.setHost(newHost);
		hgi.setHostGroup(hg);
		hgi.commit();
	}

	return newHost;
}
开发者ID:EntityFXCode,项目名称:arsenalsuite,代码行数:27,代码来源:hostbase.cpp

示例6: bind

NetUdpSocketErr LwipNetUdpSocket::bind(const Host& me)
{
  err_t err;

  if(!m_pPcb)
    return NETUDPSOCKET_MEM; //NetUdpSocket was not properly initialised, should destroy it & retry

  #if LWIP_IGMP //Multicast support enabled
  if(me.getIp().isMulticast())
  {
    DBG("This is a multicast addr, joining multicast group\r\n");
    m_multicastGroup = me.getIp();
    ip_addr_t multicastGroupAddr = m_multicastGroup.getStruct();
    err = igmp_joingroup(IP_ADDR_ANY, &multicastGroupAddr);
    if(err)
      return NETUDPSOCKET_IF; //Could not find or create group
  }
  #endif

  err = udp_bind( (udp_pcb*) m_pPcb, IP_ADDR_ANY, me.getPort()); //IP_ADDR_ANY : Bind the connection to all local addresses
  if(err)
    return NETUDPSOCKET_INUSE;

  //Setup callback
  udp_recv( (udp_pcb*) m_pPcb, LwipNetUdpSocket::sRecvCb, (void*) this );

  return NETUDPSOCKET_OK;
}
开发者ID:lukas2511,项目名称:LaosLaser_Dirty,代码行数:28,代码来源:lwipNetUdpSocket.cpp

示例7: if

csp::WorkResult::Enum csp::Process::Evaluate( Host& host, int numArgs )
{
	if( LuaThread().Status() != lua::Return::YIELD && LuaThread().Status() != lua::Return::OK )
		return WorkResult::FINISH;

	if( m_operation )
	{
		WorkResult::Enum result = m_operation->IsFinished()
			? WorkResult::FINISH
			: m_operation->Evaluate( host );

		if( result == WorkResult::FINISH )
		{
			lua::LuaStack luaStack = m_luaThread.GetStack();
			numArgs = m_operation->PushResults( luaStack );
			DeleteOperation( host );
		}
		else
			return WorkResult::YIELD;
	}
	
	WorkResult::Enum result = Resume( numArgs );
	
	if ( result == WorkResult::YIELD && m_operation )
		host.PushEvalStep( *this );
	else if ( result == WorkResult::FINISH && m_parentProcess )
	{
		if( host.GetTopProcess() != m_parentProcess )
			host.PushEvalStep( *m_parentProcess );
	}

	return result;
}
开发者ID:losinggeneration,项目名称:LuaCSP,代码行数:33,代码来源:process.cpp

示例8: ASSERT

void Loader::load(DocLoader* docLoader, CachedResource* resource, bool incremental, bool skipCanLoadCheck, bool sendResourceLoadCallbacks)
{
    ASSERT(docLoader);
    Request* request = new Request(docLoader, resource, incremental, skipCanLoadCheck, sendResourceLoadCallbacks);

    Host* host;
    KURL url(resource->url());
    bool isHTTP = url.protocolIs("http") || url.protocolIs("https");
    if (isHTTP) {
        AtomicString hostName = url.host();
        host = m_hosts.get(hostName.impl());
        if (!host) {
            host = new Host(hostName, maxRequestsInFlightPerHost);
            m_hosts.add(hostName.impl(), host);
        }
    } else 
        host = &m_nonHTTPProtocolHost;
    
    Priority priority = determinePriority(resource);
    host->addRequest(request, priority);
    docLoader->incrementRequestCount();

    if (priority > Low || !isHTTP) {
        // Try to request important resources immediately
        host->servePendingRequests(priority);
    } else {
        // Handle asynchronously so early low priority requests don't get scheduled before later high priority ones
        scheduleServePendingRequests();
    }
}
开发者ID:acss,项目名称:owb-mirror,代码行数:30,代码来源:loader.cpp

示例9:

void		TcpCSocket::prepare(Host const& host)
{
  if (this->connected())
    this->disconnect();
  this->_s_in.sin_addr = host.getAddrN();
  this->_s_in.sin_port = host.getPortN();
}
开发者ID:Hugal31,项目名称:SpaceInvaders,代码行数:7,代码来源:TcpCSocket.cpp

示例10: remove

bool Leafset::remove(const Host& entry)
{
	pf_log[W_ROUTING] << "Trying to remove an entry from the leafset: " << entry;
	if(entry.GetKey() == this->me.GetKey())
	{
		pf_log[W_ROUTING] << "Trying to remove myself from the leafset ?";
		return false;
	}

	HostVector::iterator it;

	for (it = leavesCW.begin(); it != leavesCW.end(); ++it)
	{
		if(entry.GetKey() == it->GetKey())
		{
			pf_log[W_ROUTING] << "Entry removed.";
			leavesCW.erase(it);
			return true;
		}
	}
	for (it = leavesCCW.begin(); it != leavesCCW.end(); ++it)
	{
		if(entry.GetKey() == it->GetKey())
		{
			pf_log[W_ROUTING] << "Entry removed.";
			leavesCCW.erase(it);
			return true;
		}
	}
	return false;
}
开发者ID:TheArboreProject,项目名称:Arbore-DHT,代码行数:31,代码来源:leafset.cpp

示例11: debug

void SyncedSDFileSystem::on_master_event(TCPSocketEvent e) {
  debug("MASTER: got event: %d", e);
  TCPSocketErr err;
  Host slave;
  TCPSocket *slave_socket;
  MasterNodeHandler *dispatcher;

  switch (e) {
    case TCPSOCKET_ACCEPT:
      debug("MASTER: accepting new connection");
      err = tcp_socket_->accept(&slave, &slave_socket);
      if (err) {
        // TODO: handle errors
      }
      debug("MASTER: creating new handler");
      dispatcher = new MasterNodeHandler(this, slave, slave_socket);
      node_handlers_.insert(pair<string, MasterNodeHandler *>(ip_to_string(slave.getIp()), dispatcher));
      // dispatcher should destroy self when done or disconnected
      break;
    case TCPSOCKET_CONTIMEOUT:
    case TCPSOCKET_CONRST:
    case TCPSOCKET_CONABRT:
    case TCPSOCKET_ERROR:
    case TCPSOCKET_DISCONNECTED:
      // TODO: handle errors
      break;
    case TCPSOCKET_CONNECTED:
    case TCPSOCKET_READABLE:
    case TCPSOCKET_WRITEABLE:
     default:
      // these should never happen
      break;
  }
}
开发者ID:intervigilium,项目名称:csm213a-embedded,代码行数:34,代码来源:synced_sd_filesystem.cpp

示例12: Handle

	void Handle (DHT& dht, const Host& host, const Packet& pckt)
	{
		Key k = pckt.GetArg<Key>(DHT_GET_KEY);
		pf_log[W_DHT] << "Get received with key " << k;

		if(dht.GetStorage()->hasKey(k))
		{
			pf_log[W_DHT] << "Answer with data " << dht.GetStorage()->getInfo(k)->GetStr();
			Packet get_ack(DHTGetAckType, dht.GetMe(), host.GetKey());
			get_ack.SetArg(DHT_GET_ACK_KEY, k);
			get_ack.SetArg(DHT_GET_ACK_DATA, dht.GetStorage()->getInfo(k));
			if(!dht.GetChimera()->Send(host, get_ack))
				pf_log[W_DHT] << "Send get ACK message failed!";
			return;
		}

		pf_log[W_DHT] << "Data not in cache, try to relay to a closest host.";
		if(!dht.GetChimera()->Route(pckt))
		{
			pf_log[W_DHT] << "I'm the owner and the key is unknow, answer with GET_NACK.";
			Packet get_nack(DHTGetNAckType, dht.GetMe(), host.GetKey());
			get_nack.SetArg(DHT_GET_NACK_KEY, k);
			if(!dht.GetChimera()->Send(host, get_nack))
				pf_log[W_DHT] << "Send get NACK message failed!";
			return;
		}
		pf_log[W_DHT] << "GET relayed.";
	}
开发者ID:TheArboreProject,项目名称:Arbore-DHT,代码行数:28,代码来源:messages.cpp

示例13: onReceive

				// InStream::ReceiveHandler implementation
				virtual void onReceive(const void* data, int size)
				{
					std::string key = remoteHost.keyStr();
					if (os.isValid()) {
						// -> already initialized
						std::string s((char*) data, size);
						printf("Received %d bytes from %s: %s\n", size, key.c_str(), s.c_str());
						server.broadcastMessage(data, size);
					} else {
						// -> connect outstream
						if (size == sizeof(ServiceId)) {
							ServiceId service = *((ServiceId*) data);
							printf("Received client callback service id %d from %s\n", service, key.c_str());
							os = remoteHost.connect(service);
							ready = true;
							sendMessage("HELLO", 6);
						} else {
							// invalid init message
							printf("Received invalid callback service id from %s\n", key.c_str());
							is.reset();
							server.removeConnection(this);
							delete this;
							return;
						}
					}
					is.read(this);
				}
开发者ID:cusnir,项目名称:gocusp,代码行数:28,代码来源:server.cpp

示例14:

// -----------------------------------
void	Cookie::logDebug(const char *str, int ind)
{
	char ipstr[64];
	Host h;
	h.ip = ip;
	h.IPtoStr(ipstr);

	LOG_DEBUG("%s %d: %s - %s",str,ind,ipstr,id);
}
开发者ID:tempbottle,项目名称:TestSet,代码行数:10,代码来源:http.cpp

示例15: isCompatible

bool Provider::isCompatible(const Host& host) const {
	// check compatibility with host
	const std::string& type = this->plumaGetType();
	if (!host.knows(type)) return false;
	unsigned int lowest = host.getLowestVersion(type);
	unsigned int current = host.getVersion(type);
	unsigned int myVersion = this->getVersion();
	return lowest <= myVersion && myVersion <= current;
}
开发者ID:bjqiwei,项目名称:uscxml,代码行数:9,代码来源:Provider.cpp


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