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


C++ ConnectionPtr类代码示例

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


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

示例1: LoadCache

void CPage::LoadCache(ConnectionPtr connection)
{
	Trace("LoadCache", "",0);

    ResultPtr result;
	ncc::safe_array<char> strQuery(10240);

	try
	{
		// load from the database
		snprintf(strQuery, strQuery.size(), SQL_WTT_LOAD_CACHE, m_runID);

		Trace("Query for LoadCache", strQuery, 0);
		result = connection->Query(strQuery);

		while(result->Next())
		{
			RowPtr row = result->GetCurrentRow();
			// add it
			std::string urlStr;
			urlStr = row->GetFieldString(1);
			{ // scope for lock
				Mutex::Lock lock(sm_urlListLock);
				m_totalUrlList.push_back(urlStr);
			}
		}
	}
	catch (const std::exception& e)
	{
		LogError2("LoadCache() - Caught Exception", e.what(), 0, SC_ERR_GROUP_DB, SC_ERR_CODE_LOAD_CACHE);
	}
}
开发者ID:tucci69,项目名称:tcp_ssl,代码行数:32,代码来源:page.cpp

示例2: releaseConnection

/**
 * @brief 释放MySql连接
 * @param connPtr 指定需释放的连接
 */
void MySqlConnectionPool::releaseConnection(ConnectionPtr connPtr)
{
    boost::mutex::scoped_lock lock(_mutex);
    if (connPtr.get()) {
        _connContainer.push_back(connPtr);
    }
}
开发者ID:sayi21cn,项目名称:GreenLeaf,代码行数:11,代码来源:MySqlConnectionPool.cpp

示例3: loadContentError

void CPage::loadContentError(ConnectionPtr connection)
{
	Trace("loadContentError()", "", 0);

	std::string strQuery;

	try
	{
		Mutex::Lock lock(m_contentErrorListLock);

		// get all of the pages for this customer to test
		strQuery = Format(SQL_WTT_CONTENT_ERRORS);
		if (ResultPtr result = connection->Query(strQuery))
		{
			while (result->Next())
			{
				RowPtr row = result->GetCurrentRow();

				StringIDList::value_type contentError(row->GetFieldString(1), row->GetFieldLong(2));
				contentError.first = " " + contentError.first + " ";

				Trace("loadContentError() - loading string", contentError.first.c_str(), contentError.second);
				m_contentError.push_back(contentError);
			}
		}
	}
	catch (const std::exception& e)
	{
		LogError("Exception Caught:", e.what(), 0);
	}
}
开发者ID:tucci69,项目名称:tcp_ssl,代码行数:31,代码来源:page.cpp

示例4: Register

    bool ServiceType::Register(const ConnectionPtr&                  connection,
                               const Dob::Typesystem::HandlerId&     handlerId,
                               LamportClock&                         regClock,
                               const bool                            overrideRegistration,
                               const ConsumerId&                     consumer)
    {
        const ContextId context = connection->Id().m_contextId;

        if (m_typeIsContextShared && context != 0)
        {
            std::wostringstream ostr;
            ostr << "Service " << Typesystem::Operations::GetName(m_typeId) <<
                    ", which is ContextShared, can only be registered from context 0.";
            throw Safir::Dob::Typesystem::SoftwareViolationException(ostr.str(),__WFILE__,__LINE__);
        }

        ScopedTypeLock lck(m_typeLocks[context]);

        // Important to update the registration clock with the lock taken
        RegisterTime regTime = regClock.GetNewTimestamp();

        return m_handlerRegistrations[context].Register(connection,
                                                        handlerId,
                                                        Dob::InstanceIdPolicy::RequestorDecidesInstanceId, // Dummy for services
                                                        false,           // false => no injection handler
                                                        regTime,
                                                        overrideRegistration,
                                                        consumer);
    }
开发者ID:SafirSDK,项目名称:safir-sdk-core,代码行数:29,代码来源:ServiceType.cpp

示例5: LBASSERT

void OCommand::sendHeader( const uint64_t additionalSize )
{
    LBASSERT( !_impl->dispatcher );
    LBASSERT( !_impl->isLocked );
    LBASSERT( additionalSize > 0 );

    const Connections& connections = getConnections();
    for( ConnectionsCIter i = connections.begin(); i != connections.end(); ++i )
    {
        ConnectionPtr connection = *i;
        connection->lockSend();
    }
    _impl->isLocked = true;
    _impl->size = additionalSize;
    flush( true );
}
开发者ID:qqdiguo,项目名称:Collage,代码行数:16,代码来源:oCommand.cpp

示例6: removeListenerNB

uint32_t LocalNode::removeListenerNB( ConnectionPtr connection )
{
    EQASSERT( isListening( ));
    EQASSERT( connection->isListening( ));

    connection->ref( CO_REFERENCED_PARAM );
    NodeRemoveListenerPacket packet( connection, registerRequest( ));
    Nodes nodes;
    getNodes( nodes );

    for( Nodes::iterator i = nodes.begin(); i != nodes.end(); ++i )
    {
        (*i)->send( packet, connection->getDescription()->toString( ));
    }
    return packet.requestID;
}
开发者ID:MichaelVlad,项目名称:Equalizer,代码行数:16,代码来源:localNode.cpp

示例7: _removeConnection

void LocalNode::_removeConnection( ConnectionPtr connection )
{
    EQASSERT( connection.isValid( ));

    _incoming.removeConnection( connection );

    void* buffer( 0 );
    uint64_t bytes( 0 );
    connection->getRecvData( &buffer, &bytes );
    EQASSERTINFO( !connection->isConnected() || buffer, *connection );
    EQASSERT( !buffer || bytes == sizeof( uint64_t ));

    if( !connection->isClosed( ))
        connection->close(); // cancels pending IO's
    delete reinterpret_cast< uint64_t* >( buffer );
}
开发者ID:MichaelVlad,项目名称:Equalizer,代码行数:16,代码来源:localNode.cpp

示例8: loadPhraseCheck

void CPage::loadPhraseCheck(ConnectionPtr connection)
{
	Trace("loadPhraseCheck()", "", 0);

	std::string strQuery;

	try
	{
		Mutex::Lock lock(m_phraseListLock);

		strQuery = Format(SQL_WTT_PHRASE_WORDS, getPageID());
		if (ResultPtr result = connection->Query(strQuery))
		{
			Trace("RowPtr s:","",result->GetRowCount());

			while (result->Next())
			{
				RowPtr row = result->GetCurrentRow();

				StringIDList::value_type phrase(row->GetFieldString(1), row->GetFieldLong(2));

				Trace("loadPhraseCheck_LT(): pre", phrase.first.c_str(), phrase.second);
				std::transform(phrase.first.begin(), phrase.first.end(), phrase.first.begin(), tolower);
				Trace("loadPhraseCheck_LT(): post", phrase.first.c_str(), phrase.second);
				m_phrase.push_back(phrase);
			}
		}
	}
	catch (const std::exception& e)
	{
		LogError("Exception Caught:", e.what(), 0);
	}
}
开发者ID:tucci69,项目名称:tcp_ssl,代码行数:33,代码来源:page.cpp

示例9: send

bool Connection::send( const Connections& connections,
                       const Packet& packet, const bool isLocked )
{
    if( connections.empty( ))
        return true;

    bool success = true;
    for( Connections::const_iterator i= connections.begin(); 
         i<connections.end(); ++i )
    {        
        ConnectionPtr connection = *i;
        if( !connection->send( &packet, packet.size, isLocked ))
            success = false;
    }
    return success;
}
开发者ID:cstalder,项目名称:Equalizer,代码行数:16,代码来源:connection.cpp

示例10: stop

void ConnectionManager::stop(ConnectionPtr c)
{
#ifdef WT_THREADED
  std::unique_lock<std::mutex> lock{mutex_};
#endif // WT_THREADED

  std::set<ConnectionPtr>::iterator i = connections_.find(c);
  if(i != connections_.end()) {
    connections_.erase(i);
  } else {
#ifndef WT_WIN32
    /*
     * Error you may get when multiple transmitMore() were outstanding
     * during server push, and the last one indicated that the connection
     * needed to be closed: as a consequence they will all try to close
     * the connection.
     */
    /*
      LOG_DEBUG("ConnectionManager::stop(): oops - stopping again?");
    */
    return;
#endif // WIN32
  }

  LOG_DEBUG("removed connection (#" << connections_.size() << ")");

#ifdef WT_THREADED
  lock.unlock();
#endif // WT_THREADED

  c->scheduleStop();
}
开发者ID:AlexanderKotliar,项目名称:wt,代码行数:32,代码来源:ConnectionManager.C

示例11: addConnection

void ConnectionManager::addConnection(const ConnectionPtr& conn)
{
  boost::mutex::scoped_lock lock(connections_mutex_);

  connections_.insert(conn);
  conn->addDropListener(boost::bind(&ConnectionManager::onConnectionDropped, this, _1));
}
开发者ID:rosmod,项目名称:rosmod-comm,代码行数:7,代码来源:rosmod_connection_manager.cpp

示例12: Unregister

    void ServiceType::Unregister(const ConnectionPtr&                connection,
                                 const Dob::Typesystem::HandlerId&   handlerId)
    {
        const ContextId context = connection->Id().m_contextId;

        if (m_typeIsContextShared && context != 0)
        {
            std::wostringstream ostr;
            ostr << "Service " << Typesystem::Operations::GetName(m_typeId) <<
                    ", which is ContextShared, can only be unregistered from context 0.";
            throw Safir::Dob::Typesystem::SoftwareViolationException(ostr.str(),__WFILE__,__LINE__);
        }

        ScopedTypeLock lck(m_typeLocks[context]);

        if (handlerId == Dob::Typesystem::HandlerId::ALL_HANDLERS)
        {
            m_handlerRegistrations[context].UnregisterAll(connection,
                                                          true);     // true => explicit unregister
        }
        else
        {
            m_handlerRegistrations[context].Unregister(connection, handlerId);
        }
    }
开发者ID:SafirSDK,项目名称:safir-sdk-core,代码行数:25,代码来源:ServiceType.cpp

示例13: lock

void HttpServer::destroy(ConnectionPtr connection, bool release)
{
    connection->markToBeDeleted();

    {
        std::lock_guard<std::mutex> lock(connections_mutex_);
        auto it = std::find_if(std::begin(connections_),
                               std::end(connections_),
                               [&](ConnectionPtr conn)
                               { return connection == conn; });
        if (it == std::end(connections_))
        {
            return;
        }
        else
        {
            --connection_count_;
            connections_.erase(it);
        }
    }

    if (release)
    {
        HTTP::Connection::release(connection);
    }
}
开发者ID:0x7f,项目名称:httpp,代码行数:26,代码来源:HttpServer.cpp

示例14: serialize

bool LocalNode::listen()
{
    EQVERB << "Listener data: " << serialize() << std::endl;
    if( !isClosed() || !_connectSelf( ))
        return false;

    ConnectionDescriptions descriptions = getConnectionDescriptions();
    for( ConnectionDescriptions::const_iterator i =
             descriptions.begin(); i != descriptions.end(); ++i )
    {
        ConnectionDescriptionPtr description = *i;
        ConnectionPtr connection = Connection::create( description );

        if( !connection )
            continue;

        if( !connection->listen( ))
        {
            EQWARN << "Can't create listener connection: " << description
                   << std::endl;
            return false;
        }

        _connectionNodes[ connection ] = this;
        _incoming.addConnection( connection );
        if( description->type >= CONNECTIONTYPE_MULTICAST )
        {
            MCData data;
            data.connection = connection;
            data.node = this;
            _multicasts.push_back( data );
        }

        connection->acceptNB();

        EQVERB << "Added node " << _id << " using " << connection << std::endl;
    }
    
    _state = STATE_LISTENING;
    
    EQVERB << base::className( this ) << " start command and receiver thread "
           << std::endl;
    _receiverThread->start();

    EQINFO << *this << std::endl;
    return true;
}
开发者ID:MichaelVlad,项目名称:Equalizer,代码行数:47,代码来源:localNode.cpp

示例15: create

ConnectionPtr Connection::create( ConnectionDescriptionPtr description )
{
    ConnectionPtr connection;
    switch( description->type )
    {
    case CONNECTIONTYPE_TCPIP:
    case CONNECTIONTYPE_SDP:
        connection = new SocketConnection( description->type );
        break;

    case CONNECTIONTYPE_PIPE:
        connection = new PipeConnection;
        break;

#ifdef _WIN32
    case CONNECTIONTYPE_NAMEDPIPE:
        connection = new NamedPipeConnection;
        break;
#endif

    case CONNECTIONTYPE_RSP:
        connection = new RSPConnection;
        break;

#ifdef COLLAGE_USE_OFED
    case CONNECTIONTYPE_RDMA:
        connection = new RDMAConnection;
        break;
#endif
#ifdef COLLAGE_USE_UDT
    case CONNECTIONTYPE_UDT:
        connection = new UDTConnection;
        break;
#endif

    default:
        LBWARN << "Connection type " << description->type
               << " not supported" << std::endl;
        return 0;
    }

    if( description->bandwidth == 0 )
        description->bandwidth = connection->getDescription()->bandwidth;

    connection->_setDescription( description );
    return connection;
}
开发者ID:OlafRocket,项目名称:Collage,代码行数:47,代码来源:connection.cpp


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