示例#1
0
void Message::MergeFrom(const Message& from) {
  GOOGLE_CHECK_NE(&from, this);
  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
    if (from.has_to()) {
      set_to(from.to());
    }
    if (from.has_id()) {
      set_id(from.id());
    }
    if (from.has_time()) {
      set_time(from.time());
    }
    if (from.has_from()) {
      set_from(from.from());
    }
    if (from.has_type()) {
      set_type(from.type());
    }
    if (from.has_sn()) {
      set_sn(from.sn());
    }
    if (from.has_data()) {
      set_data(from.data());
    }
    if (from.has_expire()) {
      set_expire(from.expire());
    }
  }
}
示例#2
0
void
mastermind_t::data::cache_expire() {
	auto preferable_life_time = std::chrono::seconds(m_group_info_update_period);

	cache_is_expired = false;

#if 0
	{
		auto cache = cache_groups.copy();
		if (!cache.is_expired() && check_cache_for_expire("cache_groups", cache
					, preferable_life_time, warning_time, expire_time)) {
			cache.set_expire(true);
			cache_groups.set(cache);
		}
	}
#endif

	{
		auto cache = elliptics_remotes.copy();
		if (!cache.is_expired() && check_cache_for_expire("elliptics_remotes", cache
					, preferable_life_time, warning_time, expire_time)) {
			cache.set_expire(true);
			elliptics_remotes.set(cache);
		}
	}

	{
		auto cache_map = namespaces_states.copy();

		for (auto it = cache_map.begin(), end = cache_map.end(); it != end; ++it) {
			const auto &name = it->first;
			auto &cache = it->second;

			cache_is_expired = cache_is_expired || cache.is_expired();

			if (check_cache_for_expire("namespaces_states:" + name
						, cache, preferable_life_time, warning_time, expire_time)) {
				cache_is_expired = true;

				if (!cache.is_expired()) {
					cache.set_expire(true);
					namespaces_states.set(name, std::move(cache));
				}
			}
		}
	}
}
示例#3
0
// set item to map tile x,y. checks for errors, free space and does light.
int set_item_map(int in,int x,int y)
{
	int m;

	if (in<1 || in>=MAXITEM) {
		elog("set_item(): illegal item number %d",in);
		return 0;
	}

	if (x<1 || x>=MAXMAP || y<1 || y>MAXMAP) {
		elog("set_item(): illegal coordinates (%d,%d)",x,y);
		return 0;
	}

	if (!it[in].flags) {
		elog("set_item(): trying to drop unused item %s (%d) at %d,%d",it[in].name,in,x,y);
		return 0;
	}

        m=x+y*MAXMAP;

	if (map[m].it || (map[m].flags&(MF_TMOVEBLOCK|MF_MOVEBLOCK))) return 0;

	map[m].it=in;

	if (it[in].flags&IF_MOVEBLOCK) map[m].flags|=MF_TMOVEBLOCK;
	if (it[in].flags&IF_SIGHTBLOCK) map[m].flags|=MF_TSIGHTBLOCK;
	
	it[in].x=x;
	it[in].y=y;
	it[in].carried=0;
	it[in].contained=0;

	if (it[in].flags&IF_TAKE) set_expire(in,ITEM_DECAY_TIME);

	add_item_light(in);

	set_sector(it[in].x,it[in].y);
	//notify_area(it[in].x,it[in].y,NT_ITEM,in,0,0);

	return 1;
}