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


C++ MemPool::setMonitor方法代码示例

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


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

示例1: run

int32_t SearcherWorker::run() {
    const char *pureString = NULL;
    uint32_t pureSize = 0;
    char *resData = NULL;
    uint32_t resSize = 0;
    char *resDetailData = NULL;
    int32_t resDetailSize = 0;
    int32_t ret = 0;
    MemPool *memPool = NULL;
    int64_t *pNid = NULL;
    commdef::ClusterResult *pClusterResult = NULL;
    queryparser::QueryRewriterResult *pQRWResult = NULL;
    queryparser::QPResult *pQueryResult = NULL;
    SearchResult *pSearchResult = NULL;
    statistic::StatisticResult *pStatisticResult = NULL;
    sort_framework::SortResult *pSortResult = NULL;
    ResultSerializer resultSerial;
    FRAMEWORK::Context context;
    FILE *pOutput = NULL;
    //check session status
    FRAMEWORK::session_status_t status = _session.getStatus();
    if (status == FRAMEWORK::ss_timeout) {
        handleTimeout();
        return KS_SUCCESS;
    }
    //get query infomation
    FRAMEWORK::Query &query = _session.getQuery();
    pureSize = query.getPureQuerySize();
    pureString = query.getPureQueryData();
    if (!pureString || pureSize == 0) {
        _session.setStatus(FRAMEWORK::ss_error);
        _session.response();
        return KS_EFAILED;
    }
    //set LogInfo level
    _session._logInfo._eRole = FRAMEWORK::sr_simple;
    //get MemPool from factory
    memPool = _memFactory.make((uint64_t)(getOwner()));
    if (memPool == NULL) {
        TWARN("Make mem pool failed!");
        return KS_EFAILED;
    }
    //create memory pool monitor
    MemMonitor memMonitor(memPool, _memLimit);
    memPool->setMonitor(&memMonitor);
    memMonitor.enableException();
    //initialize context class
    context.setMemPool(memPool);
	//initialize format processor
    _formatProcessor.init(memPool);
    //Deal with search proccess
    do{  
        if(_session.isHttp()){
            pQRWResult = NEW(memPool, queryparser::QueryRewriterResult)();
            if (pQRWResult == NULL) {
                TWARN("SEARCHER: new Result no mem");
                _session.setStatus(FRAMEWORK::ss_error);
                break;
            }
        }
        pQueryResult = NEW(memPool, queryparser::QPResult)(memPool);
        pSearchResult = NEW(memPool, SearchResult);
        pStatisticResult = NEW(memPool, statistic::StatisticResult); 
        pSortResult = NEW(memPool, sort_framework::SortResult)(memPool);
        if(unlikely(!pQueryResult || !pSearchResult || !pStatisticResult
                    || !pSortResult)) {
            TWARN("SEARCHER: new Result no mem");
            _session.setStatus(FRAMEWORK::ss_error);
            break;
        }
        //add queryrewrite process
        if(_session.isHttp()){     
            ret = _qrewriter.doRewrite(&context, pureString, pureSize, pQRWResult);
            if (timeoutCheck && (_timeout > 0) && (_session.getLatencyTime() > _timeout)) {
                _session.setStatus(FRAMEWORK::ss_timeout);
                TWARN("SEARCHER: qrewriter.doRewrite function over time. query is %s", pureString);
                break;
            }
            if (unlikely(ret != KS_SUCCESS)) {
                _session.setStatus(FRAMEWORK::ss_error);
                TWARN("qrewriter.doRewrite function error. query is %s", pureString);                
                break;
            }
            pureString = pQRWResult->getRewriteQuery();
        }
        //end add
        ret = _qp.doParse(&context, pQueryResult, pureString);
        if (timeoutCheck && (_timeout > 0) && 
                (_session.getLatencyTime() > _timeout)) 
        {
            _session.setStatus(FRAMEWORK::ss_timeout);
            TWARN("SEARCHER: qp.doParse function over time. query is %s", pureString);
            break;
        }
        if (unlikely(ret != KS_SUCCESS)){
            TWARN("SEARCHER: queryparser doParse function error. query is %s", pureString);
            _session.setStatus(FRAMEWORK::ss_error);
            break;
        }

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


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