Esempio n. 1
0
void Gsolve::setNinit( const Eref& e, double v )
{
	unsigned int vox = getVoxelIndex( e );
	if ( vox != OFFNODE ) {
		if ( e.element()->cinfo()->isA( "ZombieBufPool" ) ) {
			// Do NOT round it here, it is folded into rate term.
			pools_[vox].setNinit( getPoolIndex( e ), v );
			// refresh rates because nInit controls ongoing value of n.
			if ( sys_.isReady )
				pools_[vox].refreshAtot( &sys_ ); 
		} else {
			pools_[vox].setNinit( getPoolIndex( e ), round( v ) );
		}
	}
}
Esempio n. 2
0
double Ksolve::getNinit( const Eref& e ) const
{
    unsigned int vox = getVoxelIndex( e );
    if ( vox != OFFNODE )
        return pools_[vox].getNinit( getPoolIndex( e ) );
    return 0.0;
}
Esempio n. 3
0
		int ImAdapter::userStat(int userId){
			LOG_INFO("IMADAPTER|userStat|userId");
			size_t poolIndex = getPoolIndex(userId);
			shared_lock<shared_mutex> lock(userPoolMutex_[poolIndex]);
			UserOnlineStateMap& subPool = userOnlineStateMaps[poolIndex];
			UserOnlineStateMap::iterator it = subPool.find(userId);

			if(it != subPool.end()){
				return 1;
			}
			return 0;
		}
Esempio n. 4
0
		void ImAdapter::removeUser(const int  userId){
			/*
			 * 找到userId所属的池子
			 */
			size_t poolIndex = getPoolIndex(userId);
			unique_lock<shared_mutex> lock(userPoolMutex_[poolIndex]);
			UserOnlineStateMap& subPool = userOnlineStateMaps[poolIndex];
			UserOnlineStateMap::iterator it = subPool.find(userId);

			/*
			 * 删除离线请求对象
			 */
			if(it != subPool.end()){
				LOG_INFO("RM|"<<userId);
				subPool.erase(it);
			}
		}
Esempio n. 5
0
		void ImAdapter::offline(int userId, bool isDelLongOnline ){
			/*
			 * 按uid在池子中找到map,再在map中搜寻离线请求对象
			 */
			LOG_INFO("OFF|B|"<<userId);
			size_t poolIndex = getPoolIndex(userId);
			shared_lock<shared_mutex> lock(userPoolMutex_[poolIndex]);
			UserOnlineStateMap& subPool = userOnlineStateMaps[poolIndex];
			UserOnlineStateMap::iterator it = subPool.find(userId);

			if(it == subPool.end()){
				// 离线请求对象不存在时,不做任何事
			}else{

				// 生成map中的离线请求对象的指针
				UserOnlineStatePtr statePtr = it->second;

				// 此条件表示 仅接受 有效的offline下线请求,非法的连续多次的下线请求仅仅接受或者说承认第一次请求,重复连续发出的离线请求会被废弃
				if(statePtr->cushionState == ONLINE){
					/*
					 * 缓冲状态改变
					 */
					// 将离线请求对象的缓冲状态置为离线
					statePtr->cushionState = OFFLINE;

					/*
					 * 离线请求缓冲队列增加一项,map中的字段相应变化
					 */
					// 在时间戳队列中压入当前时间
					statePtr->timeQueue.push_back(time(NULL));
					// 离线请求缓冲队列请求总数加一
					{
						boost::mutex::scoped_lock lock(statePtr->countMutex);
						statePtr->offlineCount++;
					}
					// 锁定离线缓冲请求队列,压入请求对象指针
					size_t queueIndex = getQueueIndex(userId);
					unique_lock<shared_mutex> lock(stateBufferMutex_[queueIndex]);
					stateBuffer_[queueIndex].push_back(statePtr);
				}else{
					//非法的重复offline请求,此情况实际不出现,这里进行容错
					statePtr->cushionState = OFFLINE;
				}
			}
		}
Esempio n. 6
0
void Ksolve::setNinit( const Eref& e, double v )
{
    unsigned int vox = getVoxelIndex( e );
    if ( vox != OFFNODE )
        pools_[vox].setNinit( getPoolIndex( e ), v );
}
Esempio n. 7
0
		/*
		 * 上线接口
		 */
		void ImAdapter::online(int userId, bool isLongOnline, std::string onlineIp){
			/*
			 * 按uid在池子中找到map,再在map中搜寻离线请求对象
			 */
			size_t poolIndex = getPoolIndex(userId);
			unique_lock<shared_mutex> lock(userPoolMutex_[poolIndex]);
			UserOnlineStateMap& subPool = userOnlineStateMaps[poolIndex];
			UserOnlineStateMap::iterator it = subPool.find(userId);

			if(it != subPool.end()){
				/*
				 * 已经存在的离线请求对象的情况
				 */
				UserOnlineStatePtr statePtr = it->second;
				//如果用户存在且im在线,此条件一直为真
				if(statePtr->imState == ONLINE){
					// 将缓冲状态置为在线
					statePtr->cushionState = ONLINE;
					// 更新登录IP
					statePtr->onlineIp = onlineIp;
					// 打印日志,特别说明more,表明是在离线请求受到缓冲的情况下进行的上线操作
					LOG_INFO("ON|M|"<<userId);
					// 离线请求缓冲的情况下上线行为不立即引发对IM对象上线接口的调用
				}else if(statePtr->imState == OFFLINE){
					//此种状态不存在
				}
			}else{
				/*
				 * map中不存在uid对应的离线请求对象时,需要新建
				 */
				// 新建离线请求对象
				UserOnlineStatePtr statePtr(new UserOnlineState);

				/*
				 * 初始化工作
				 */
				// 初始化其uid
				statePtr->userId = userId;
				// 在线状态初始化为在线
				statePtr->imState = ONLINE;
				statePtr->cushionState = ONLINE;
				// 离线请求总数初始化为0
				statePtr->offlineCount = 0;
				// 更新登录IP
				statePtr->onlineIp = onlineIp;

				/*
				 * 初始化结束
				 */
				// 离线请求对象放入池子的所属map,不进入离线缓冲队列
				subPool[userId] = statePtr;	

				/*
				 * 日志打印
				 */
				// 打印日志,输出上线用户的uid
				LOG_INFO("ON|N|"<<userId);

				/*
				 * 调用im接口通知上线,上线请求行为不进行缓冲
				 */
				//此处调用im借口上线
				iMGateForPhoneAdapter_.online(userId);
			}

		}