本文整理汇总了C++中HashIterator::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ HashIterator::remove方法的具体用法?C++ HashIterator::remove怎么用?C++ HashIterator::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashIterator
的用法示例。
在下文中一共展示了HashIterator::remove方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_update
void CoroutineService::on_update(const int64_t now){
Super::on_update(now);
// wakeup sleeper
if(m_sleeper_table->size() > 0){
// prepare wake up list
Int64Array* wake_list =0;
HashIterator* it =static_cast< HashIterator* >(m_sleeper_table->iterator());
while(it->next()){
Int64* cr_id =static_cast< Int64* >(it->getKey());
Int64* expire_time =static_cast< Int64* >(it->getValue());
if(expire_time->getValue() > now){
if(!wake_list){
wake_list =SafeNew<Int64Array>();
}
wake_list->push_back(cr_id->getValue());
it->remove();
}
}
// wake up
const int64_t n =wake_list ? wake_list->size() : 0;
for(int64_t i=0; i<n; ++i){
_resume_coroutine(wake_list->get(i), SafeNew<Error>(ErrorCode::TIMEOUT), 0);
}
}
// update
int64_t cr_new_id=0;
m_cr_pool->go(_update, 0, cr_new_id);
}
示例2: removeIf
void Hash::removeIf(bool (*pfn)(Object*, Object*)){
if(!pfn) return;
HashIterator* it =dynamic_cast<HashIterator*>(iterator());
while(it->next()){
if(pfn(it->getKey(), it->getValue())){
it->remove();
}
}
}
示例3: _process_timeout
void CommandService::_process_timeout(const int64_t now) {
/* clear timeout command */
if(m_queue_tb->size()>0) {
Int64Array* ls =0;
HashIterator* it =static_cast< HashIterator* >(m_queue_tb->iterator());
while(it->next()) {
const int64_t who =static_cast< Int64* >(it->getKey())->getValue();
Array* queue =static_cast< Array* >(it->getValue());
while(Command* cmd =dynamic_cast< Command* >(queue->front())) {
if(cmd->isTimeout(now)) {
if(cmd->isProcessing()) {
WARN("service %s(%lld) who %lld command %lld cancel", name(), (long long)m_id, (long long)cmd->getWho(), (long long)cmd->getCommand());
}
queue->pop_front();
}
else {
break;
}
}
if(Command* cmd =dynamic_cast< Command* >(queue->front())) {
if(cmd->isProcessing()) {
continue;
}
ASSERT(cmd->isInit());
if(!ls) {
ls =SafeNew<Int64Array>();
}
ls->push_back(who);
}
}
const int64_t n= ls ? ls->size() : 0;
for(int64_t i=0; i<n; ++i) {
_process_request(ls->get(i));
}
}
/* clear timeout rpc */
if(m_rpc_tb->size()>0) {
Array* ls =0;
HashIterator* it =static_cast< HashIterator* >(m_rpc_tb->iterator());
while(it->next()) {
RpcInfo* ri =static_cast< RpcInfo* >(it->getValue());
if(now >= ri->getExpireTime()) {
if(!ls) {
ls =SafeNew<Array>();
}
ls->push_back(ri);
it->remove();
}
}
const int64_t n =ls ? ls->size() : 0;
for(int64_t i=0; i<n; ++i) {
RpcInfo* ri =static_cast< RpcInfo* >(ls->get(i));
WARN("service %s(%lld) rpc %lld cancel", name(), (long long)m_id, (long long)ri->getId());
ri->timeout();
}
}
}
示例4: _optimize
void CommandService::_optimize(const int64_t now) {
if(m_queue_tb->size() > OPTIMIZE_THRESHOLD) {
HashIterator* it =static_cast< HashIterator* >(m_queue_tb->iterator());
while(it->next()) {
Array* queue =static_cast< Array* >(it->getValue());
if(queue->empty()) {
it->remove();
}
}
m_queue_tb->optimize(0);
}
}
示例5: _get_need_unload_service_id
Int64Array* ServiceManager::_get_need_unload_service_id(){
std::lock_guard<LOCK_TYPE> guard(m_lock);
if(m_unloading_service_tb->empty()){
return 0;
}
const int64_t now =DateTime::Now();
Int64Array* arr =SafeNew<Int64Array>();
HashIterator* it =static_cast< HashIterator* >(m_unloading_service_tb->iterator());
while(it->next()){
const int64_t id_srv =static_cast< Int64* >(it->getKey())->getValue();
const int64_t t =static_cast< Int64* >(it->getValue())->getValue();
if(now >= t){
arr->push_back(id_srv);
it->remove();
}
}
return arr;
}