Esempio n. 1
0
void downloader_init() {
	logging_log("Donwloader", LOGGING_LEVEL_INFO, "downloader_init()");
	
	configuration = configuration_get();
	
	downloader_requests_queue = queue_construct();
	downloader_files_free_queue = queue_construct();
	
	downloader_requests_cond = (pthread_cond_t*)malloc(sizeof(pthread_cond_t));
	pthread_cond_init(downloader_requests_cond, NULL);
	
	downloader_files
			= al_dictionary_construct((char(*)(const void *, const void *))&string_compare);
	downloader_files_size = 0;
	
	downloader_files_mutex = (pthread_mutex_t*)malloc(sizeof(pthread_mutex_t));
	pthread_mutex_init(downloader_files_mutex, NULL);
	
	thread_counter_mutex = (pthread_mutex_t*)malloc(sizeof(pthread_mutex_t));
	pthread_mutex_init(thread_counter_mutex, NULL);
	
	thread_terminating = (pthread_cond_t*)malloc(sizeof(pthread_cond_t));
	pthread_cond_init(thread_terminating, NULL);
	
	for(uint8_t i = 0; i < configuration->downloader_threads_number; ++i) {
		pthread_t worker_thread;
		pthread_create(&worker_thread, NULL, (void *(*)(void *))&downloader_do_work, (void*)NULL);
	}
}
Esempio n. 2
0
File: lcp.c Progetto: giavjeko/bio
// Compute lcp for given Wavelet tree with data
void compute_lcp(Wtree* wtree, int* dst, int len) {
  int i, begin, end, l;
  Queue* queue = queue_construct();
  List* list = list_construct();
  Element* element;

  dst[1] = -1;
  dst[len + 1] = -1;
  for (i = 2; i <= len; i++) {
    dst[i] = -2;
  }

  queue_push(queue, 1, len, 0);
  while(!queue_empty(queue)) {
    queue_pop(queue, &begin, &end, &l);
    list = wtree_get_intervals(wtree, begin, end);
    for (element = list->head; element; element=element->next) {
      if (dst[element->end + 1] == -2) {
        queue_push(queue, element->begin, element->end, l + 1);
        dst[element->end + 1] = l;
      }
    }
    list_destroy(list);
  }
}
Esempio n. 3
0
/**
 * @brief This function initialises the flooding component.
 *
 * \latexonly \\ \\ \endlatexonly
 * \em Detailed \em description \n
 * This function initialises the flooding component. It also connects to the GNUnet core.
 */
void gnunet_search_flooding_init() {
	gnunet_search_flooding_message_queue = queue_construct();
	gnunet_search_flooding_routing_table = (struct gnunet_search_flooding_routing_entry *) GNUNET_malloc(
			sizeof(struct gnunet_search_flooding_routing_entry) * GNUNET_SEARCH_FLOODING_ROUTING_TABLE_SIZE);
	gnunet_search_flooding_routing_table_length = 0;
	gnunet_search_flooding_routing_table_index = 0;
	_gnunet_search_flooding_message_notification_handler = NULL;

	static struct GNUNET_CORE_MessageHandler core_handlers[] = { { &gnunet_search_flooding_core_inbound_notify,
			GNUNET_MESSAGE_TYPE_SEARCH_FLOODING, 0 }, { NULL, 0, 0 } };

	gnunet_search_flooding_core_handle = GNUNET_CORE_connect(gnunet_search_globals_cfg, 42, NULL, NULL, NULL, NULL,
			NULL/*&gnunet_search_flooding_core_inbound_notify*/, 0, NULL, 0, core_handlers);

	gnunet_search_flooding_handlers_set(&gnunet_search_flooding_message_notification_handler);
}