Example #1
0
Scheduler::PhysicalTaskPtr
Scheduler::take_runnable_task(const Locality &locality){
	const auto tid = locality.self_thread_id();
	PhysicalTaskPtr task;
	// try to take an unstealable task
	task = take_unstealable_task(locality);
	if(task){ return task; }
	// try to take a local stealable task
	task = take_local_stealable_task(locality);
	if(task){ return task; }
	// try to steal an task
	task = steal_task(locality);
	if(task){ return task; }
	// attempt to sleep
	auto &sync = m_synchronizers[tid];
	while(true){
		sync.set_is_sleeping();
		if(task || is_finished() || is_cancelled()){ break; }
		// try to take an unstealable task
		task = take_unstealable_task(locality);
		if(task){ break; }
		// try to steal an task
		task = steal_task(locality);
		if(task){ break; }
		// wait for new task
		sync.wait();
	}
	sync.reset_is_sleeping();
	return task;
}
Example #2
0
int MainProgressBar::update(int64_t value)
{
// Print ETA on title
	double current_eta = (double)eta_timer->get_scaled_difference(1000);

//printf("MainProgressBar::update %f %f %f\n", current_eta, last_eta, current_eta - last_eta);
	if(current_eta - last_eta > 1000)
	{
		char string[BCTEXTLEN];
		char time_string[BCTEXTLEN];
		double eta;

		if(value > 0.001)
			eta = (double)current_eta / 
				1000 * 
				length / 
				value - 
				current_eta / 
				1000;
		else
			eta = 0;

//printf("MainProgressBar::update %f %d %d %f\n", current_eta, length, value, eta);
 		Units::totext(time_string, 
 			eta,
 			TIME_HMS2);
// 		sprintf(time_string, 
// 			"%dh%dm%ds", 
// 			(int64_t)eta / 3600,
// 			((int64_t)eta / 60) % 60,
// 			(int64_t)eta % 60);

		sprintf(string, _("%s ETA: %s"), 
			default_title, 
			time_string);
		update_title(string, 0);

		last_eta = (int64_t)current_eta;
	}

	if(progress_box)
	{
		progress_box->update(value, 1);
	}
	else
	if(progress_bar)
	{
		mwindow->gui->lock_window("MainProgressBar::update");
		progress_bar->update(value);
		mwindow->gui->unlock_window();
	}

	return is_cancelled();
}
  void run(InstanceKlass* root) {
    ALGO* algo = static_cast<ALGO*>(this);

    reset_iteration();

    void* algo_data = algo->new_node_data(root);
    push(root, algo_data);
    bool top_needs_visit = true;

    do {
      Node* top = current_top();
      if (top_needs_visit) {
        if (algo->visit() == false) {
          // algorithm does not want to continue along this path.  Arrange
          // it so that this state is immediately popped off the stack
          top->set_super_visited();
          top->set_all_interfaces_visited();
        }
        top_needs_visit = false;
      }

      if (top->has_visited_super() && top->has_visited_all_interfaces()) {
        algo->free_node_data(top->_algorithm_data);
        pop();
      } else {
        InstanceKlass* next = NULL;
        if (top->has_visited_super() == false) {
          next = top->next_super();
          top->set_super_visited();
        } else {
          next = top->next_interface();
          top->increment_visited_interface();
        }
        assert(next != NULL, "Otherwise we shouldn't be here");
        algo_data = algo->new_node_data(next);
        push(next, algo_data);
        top_needs_visit = true;
      }
    } while (!is_cancelled() && has_more_nodes());
  }
Example #4
0
 bool is_canceled() const {
   return is_cancelled();
 }
Example #5
0
void zmodem_recv_task(intptr_t unused) {
	int file_bytes; //, ftime, total_files, total_bytes;
	int i;

	wait_file_sender();
	i=zmodem_recv_init(&zm);

#if 1
	if (zm.cancelled) {
		recv_ercd = E_TMOUT;
		goto error_exit;
	}

	if (i != ZFILE) {
		recv_ercd = E_OBJ;
		goto error_exit;
	}

	assert(i == ZFILE);
	SAFECOPY(recv_file_name,zm.current_file_name);
	file_bytes = zm.current_file_size;
	if (p_recv_filesz != NULL) *p_recv_filesz = file_bytes;
	syslog(LOG_DEBUG, "%s(): Incoming filename: %s, size: %d", __FUNCTION__, recv_file_name, file_bytes);
	bitmap_draw_string("Name: ", global_brick_info.lcd_screen, 0, offset_y, global_brick_info.font_w10h16, ROP_COPY);
	bitmap_draw_string(zm.current_file_name, global_brick_info.lcd_screen, strlen("Name: ") * 10, offset_y, global_brick_info.font_w10h16, ROP_COPY);
	offset_y += global_brick_info.font_w10h16->height;

#else
	BOOL	success=FALSE;

	if (zm.cancelled)
		return(1);
	if(i<0)
		return(-1);
	switch(i) {
		case ZFILE:
			SAFECOPY(recv_file_name,zm.current_file_name);
			file_bytes = zm.current_file_size;
//			ftime = zm.current_file_time;
//			total_files = zm.files_remaining;
//			total_bytes = zm.bytes_remaining;
			if (p_recv_filesz != NULL) *p_recv_filesz = file_bytes;
			syslog(LOG_DEBUG, "%s(): Incoming filename: %s, size: %d", __FUNCTION__, recv_file_name, file_bytes);
			break;
		case ZFIN:
		case ZCOMPL:
			return(!success);
		default:
			return(-1);
	}
#endif

	int errors = zmodem_recv_file_data(&zm, recv_file,0);
	if (errors > zm.max_errors || is_cancelled(&zm)) {
		assert(errors <= zm.max_errors);
		recv_ercd = E_TMOUT;
		goto error_exit;
	} else if (errors > 0) {
		syslog(LOG_WARNING, "%s(): Final errors %d", __FUNCTION__, errors);
	}

	i = zmodem_recv_init(&zm);
	if (i != ZFIN && i != ZCOMPL) {
		syslog(LOG_ERROR, "%s(): Last header has an unexpected type %d", __FUNCTION__, i);
		recv_ercd = E_TMOUT;
		goto error_exit;
	}

//	syslog(LOG_DEBUG, "%s(): Endpos %d", __FUNCTION__, mycookie.endpos);
	recv_ercd = E_OK;

error_exit:
	recv_task_compl = true;
	return;
}