Example #1
0
void Grid::RetrieveSitesInCell(vector<SiteValue>& result, int col, int row,
                               int x1, int y1, int x2, int y2, int tq) {
	auto p_bucket = get_mutable_instance().grid[col][row].get(); {
		lock_guard<mutex>{g_mutex[col][row]};
		g_reader[col][row] += 1;
		for (int i = p_bucket->current_ - 1; i >= 0; i--) {
			auto site = p_bucket->sites_[i].Value();
			if (site.x >= x1 && site.x <= x2
				&& site.y >= y1 && site.y <= y2
				&& (site.tu >= tq || site.tu >= tq))
				result.emplace_back(p_bucket->sites_[i].Value());
		}
	}
	p_bucket = p_bucket->next_.get();
	while (p_bucket) {
		for (int i = p_bucket->current_ - 1; i >= 0; i--) {
			auto site = p_bucket->sites_[i].Value();
			if (site.x >= x1 && site.x <= x2
				&& site.y >= y1 && site.y <= y2
				&& (site.tu >= tq || -site.tu >= tq))
				result.emplace_back(p_bucket->sites_[i].Value());
		}
		p_bucket = p_bucket->next_.get();
	}

	g_reader[col][row] -= 1;
}
Example #2
0
		static void teardown() throw() {
			if (is_destroyed()) {
				return;
			}
			scoped_lock_type lock(mutex());
			thread_callback& self = get_mutable_instance();
			self.dispose();
		}
Example #3
0
		static void setup() {
			if (is_destroyed()) {
				return;
			}
			scoped_lock_type lock(mutex());
			thread_callback& self = get_mutable_instance();
			self.initialize();
		}
Example #4
0
void LfGrid::RetrieveAllSitesInCell(vector<SiteValue>& result, int col, int row) {
	auto p_bucket = get_mutable_instance().grid[col][row].get(); 

	while (p_bucket) {
//		for (int i = p_bucket->current_ - 1; i >= 0; i--)
//			result.emplace_back(p_bucket->sites_[i].Value());
//		p_bucket = p_bucket->next_.get();
	}
}
Example #5
0
		static bool post(callback_type const& callback) {
			if (is_destroyed()) {
				return false;
			}
			scoped_lock_type lock(mutex());
			thread_callback& self = get_mutable_instance();
			self.initialize();
			self.callback_list_.push_back(callback);
			return ::PostMessage(self.window_handle_, KTL_WM_THREAD_CALLBACK, 0, 0) != 0;
		}
Example #6
0
		static bool call_one() {
			if (is_destroyed()) {
				return false;
			}
			scoped_lock_type lock(mutex());
			thread_callback& self = get_mutable_instance();
			if (self.callback_list_.empty()) {
				return false;
			}
			self.callback_list_.front()();
			self.callback_list_.pop_front();
			return true;
		}
Example #7
0
void Grid::RetrieveAllSitesInCell(vector<SiteValue>& result, int col, int row) {
	auto p_bucket = get_mutable_instance().grid[col][row].get(); {
		lock_guard<mutex>{g_mutex[col][row]};
		g_reader[col][row] += 1;
		for (int i = p_bucket->current_ - 1; i >= 0; i--)
			result.emplace_back(p_bucket->sites_[i].Value());
	}
	p_bucket = p_bucket->next_.get();
	while (p_bucket) {
		for (int i = p_bucket->current_ - 1; i >= 0; i--)
			result.emplace_back(p_bucket->sites_[i].Value());
		p_bucket = p_bucket->next_.get();
	}

	g_reader[col][row] -= 1;
}
Example #8
0
void LfGrid::RetrieveSitesInCell(vector<SiteValue>& result, int col, int row, int x1, int y1, int x2, int y2, int tq) {
	auto p_bucket = get_mutable_instance().grid[col][row].get(); {
//		for (int i = p_bucket->current_ - 1; i >= 0; i--) {
//			auto site = p_bucket->sites_[i].Value();
//			if (site.x >= x1 && site.x <= x2
//				&& site.y >= y1 && site.y <= y2
//				&& (site.tu >= tq || site.tu >= tq))
//				result.emplace_back(p_bucket->sites_[i].Value());
//		}
	}
//	p_bucket = p_bucket->next_.get();
	while (p_bucket) {
//		for (int i = p_bucket->current_ - 1; i >= 0; i--) {
//			auto site = p_bucket->sites_[i].Value();
//			if (site.x >= x1 && site.x <= x2
//				&& site.y >= y1 && site.y <= y2
//				&& (site.tu >= tq || -site.tu >= tq))
//				result.emplace_back(p_bucket->sites_[i].Value());
//		}
//		p_bucket = p_bucket->next_.get();
	}
}