예제 #1
0
	void pop_lru()
	{
		regex_node & rlu = re_list.back();
		re_list.pop_back();
		re_set.erase(rlu);
		delete &rlu;
	}
예제 #2
0
파일: Thread.cpp 프로젝트: Advi42/XCSoar
bool
Thread::Start()
{
  assert(!IsDefined());

#ifdef HAVE_POSIX
#ifndef NDEBUG
  creating = true;
#endif

  defined = pthread_create(&handle, nullptr, ThreadProc, this) == 0;

#ifndef NDEBUG
  creating = false;
#endif

  bool success = defined;
#else
  handle = ::CreateThread(nullptr, 0, ThreadProc, this, 0, &id);

  bool success = handle != nullptr;
#endif

#ifndef NDEBUG
  if (success) {
    all_threads_mutex.lock();
    all_threads.push_back(*this);
    all_threads_mutex.unlock();
  }
#endif

  return success;
}
예제 #3
0
파일: Thread.cpp 프로젝트: Advi42/XCSoar
bool
ExistsAnyThread()
{
  all_threads_mutex.lock();
  bool result = !all_threads.empty();
  all_threads_mutex.unlock();
  return result;
}
예제 #4
0
	boost::regex const & get_regex(const char * str, size_t size)
	{
		re_set_t::iterator re_in_cache = re_set.find(str, regex_hash(), regex_equal());
		if (re_in_cache != re_set.end()) {
			regex_node & node = *re_in_cache;
			bin::list<regex_node>::iterator re_in_list = bin::list<regex_node>::s_iterator_to(node);

			re_list.splice(re_list.begin(), re_list, re_in_list); // move to the begin of the list
			assert(&re_list.front() == &node);
			return node.get();
		}

		if (re_list.size() >= 64)
			pop_lru();

		regex_node * new_node = new regex_node(str, size, regex_flags);
		re_set.insert(*new_node);
		re_list.push_front(*new_node);
		return new_node->get();
	}
예제 #5
0
파일: Thread.cpp 프로젝트: Advi42/XCSoar
void
Thread::Join()
{
  assert(IsDefined());
  assert(!IsInside());

#ifdef HAVE_POSIX
  pthread_join(handle, nullptr);
  defined = false;
#else
  ::WaitForSingleObject(handle, INFINITE);
  ::CloseHandle(handle);
  handle = nullptr;
#endif

#ifndef NDEBUG
  all_threads_mutex.lock();
  all_threads.erase(all_threads.iterator_to(*this));
  all_threads_mutex.unlock();
#endif
}
예제 #6
0
파일: Thread.cpp 프로젝트: Advi42/XCSoar
bool
Thread::Join(unsigned timeout_ms)
{
  assert(IsDefined());
  assert(!IsInside());

  bool result = ::WaitForSingleObject(handle, timeout_ms) == WAIT_OBJECT_0;
  if (result) {
    ::CloseHandle(handle);
    handle = nullptr;

#ifndef NDEBUG
    {
      all_threads_mutex.lock();
      all_threads.erase(all_threads.iterator_to(*this));
      all_threads_mutex.unlock();
    }
#endif
  }

  return result;
}
예제 #7
0
int main(int argc, char* argv[])
{
    v_circular_buffer_2.push_back(1);
    v_circular_buffer_2.push_back(4);

    MyClass tmp(x);
    v_intrusive_set_2.insert(tmp);

    MyClass_list tmp_list(x);
    v_intrusive_list_2.push_front(tmp_list);

    int r = done();  // break here
    r += argc + (char)argv[0][0];
    return r % 2;
}
예제 #8
0
	~regex_lru_cache()
	{
		while (!re_list.empty()) {
			pop_lru();
		}
	}
예제 #9
0
 inline static void run(boost::intrusive::list<T, boost::intrusive::constant_time_size<false>>& c, std::size_t) {
     c.reverse();
 }