int32_t TokenManager::checkExpireContext(void) { boost::lock_guard<boost::mutex> lock(this->mMutex); while(mContextQueue.size() > 0) { ContextPtr context = mContextQueue.top(); time_t now = time(NULL); if(context->mExpireTime > now) { return context->mExpireTime - now; } context->showInfo(); std::map<std::string, ContextPtr>::iterator it = mContextDB.find(context->mKey); if(it != mContextDB.end()) mContextDB.erase(it); else printf("not found\n"); mContextQueue.pop(); } return 0; }
void TokenManager::showInfo(void) { printf("Show Map:\n"); for(std::map<std::string, ContextPtr >::iterator it=mContextDB.begin(), E=mContextDB.end(); it != E ; it++) { it->second->showInfo(); /* printf("key: %s -> expireTime: %d, token: %s, userId: %s\n", it->first.c_str(), (it->second)->mExpireTime, (it->second)->mToken.c_str(), (it->second)->mUserId.c_str()); */ } printf("Queue:\n"); while(mContextQueue.size() > 0) { ContextPtr context = mContextQueue.top(); context->showInfo(); /* printf("key: %s -> expireTime: %d, token: %s, userId: %s\n", context->mKey.c_str(), context->mExpireTime, context->mToken.c_str(), context->mUserId.c_str()); */ mContextQueue.pop(); } }