Пример #1
0
void cl_list_for_each(TScl_list *list, void (*on_element)(TScl_element *elt)) {
    TScl_element *elt = list->first;

    while (elt != NULL) {
        on_element(elt);
        elt = elt->next;
    }
}
void SpacialFinder_enumerate_area(SpacialFinder const *finder, ContinueFlag (on_element)(void *, void *), void *user)
{
	for (size_t i = 0; i < PtrVector_size(&finder->all); ++i)
	{
		void * const element = PtrVector_get(&finder->all, i);
		switch (on_element(element, user))
		{
		case Continue_Yes:
			break;

		case Continue_No:
			return;
		}
	}
}
Пример #3
0
	void callback(int num) {
		while (!m_need_exit) {
			std::unique_lock<std::mutex> guard(m_lock);
			m_pool_wait.wait_for(guard, std::chrono::milliseconds(100), [&] {return !m_elements.empty();});

			while (!m_elements.empty()) {
				std::unique_ptr<element> elm = std::move(m_elements.front());
				m_elements.pop_front();
				guard.unlock();
				m_parser_wait.notify_one();

				elm->thread_num = num;
				on_element(*elm);

				guard.lock();
			}
		}
	}