void ProcessorAdapter::global_initialize(m3bp::Task &task) {
    JNIEnv *env = java_env();
    LocalFrame frame(env, 64);

    VertexMirror *vertex = m_mirror;
    EngineMirror *engine = vertex->engine();
    engine->do_global_initialize(env, vertex, task);

    jint tasks = engine->do_task_count(env, vertex);
    if (tasks >= 0) {
        task_count(static_cast<m3bp::size_type>(tasks));
    }
    jint parallels = engine->do_max_concurrency(env, vertex);
    if (parallels >= 0) {
        max_concurrency(static_cast<m3bp::size_type>(parallels));
    }
}
Beispiel #2
0
Datei: test.c Projekt: skn/tasknc
void test_task_count() /* {{{ */
{
	/* check that the tasks are counted correctly */
	int tcnt;
	FILE *cmdout;
	char *line, *cmdstr;

	task_count();

	line = calloc(8, sizeof(char));
	asprintf(&cmdstr, "task %s count", active_filter);
	cmdout = popen(cmdstr, "r");
	fgets(line, 8, cmdout);
	pclose(cmdout);
	tcnt = atoi(line);

	test_result("task count", tcnt == taskcount);

	free(line);
} /* }}} */
Beispiel #3
0
void tasklist_window() /* {{{ */
{
	/* ncurses main function */
	int c;
	task *cur;
	char *uuid = NULL;

	/* get field lengths */
	cfg.fieldlengths.project = max_project_length();
	cfg.fieldlengths.date = DATELENGTH;

	/* create windows */
	rows = LINES;
	cols = COLS;
	tnc_fprintf(logfp, LOG_DEBUG_VERBOSE, "rows: %d, columns: %d", rows, cols);
	header = newwin(1, cols, 0, 0);
	tasklist = newwin(rows-2, cols, 1, 0);
	statusbar = newwin(1, cols, rows-1, 0);
	tnc_fprintf(logfp, LOG_DEBUG_VERBOSE, "ncurses windows: h:%p, t:%p, s:%p (%d,%d)", header, tasklist, statusbar, rows, cols);
	if (statusbar==NULL || tasklist==NULL || header==NULL)
	{
		tnc_fprintf(logfp, LOG_ERROR, "window creation failed (rows:%d, cols:%d)", rows, cols);
		ncurses_end(-1);
	}

	/* set curses settings */
	set_curses_mode(NCURSES_MODE_STD);

	/* print task list */
	check_screen_size();
	cfg.fieldlengths.description = COLS-cfg.fieldlengths.project-1-cfg.fieldlengths.date;
	task_count();
	print_header();
	tasklist_print_task_list();

	/* main loop */
	while (1)
	{
		/* set variables for determining actions */
		done = false;
		redraw = false;
		reload = false;

		/* check for an empty task list */
		if (head == NULL)
		{
			if (strcmp(active_filter,"") == 0){
				tnc_fprintf(logfp, LOG_ERROR, "it appears that your task list is empty. %s does not yet support empty task lists.", PROGNAME);
				ncurses_end(-1);
			}
			active_filter = strdup("");
			reload = true;
		}

		/* get the screen size */
		rows = LINES;
		cols = COLS;

		/* check for a screen thats too small */
		check_screen_size();

		/* check for size changes */
		check_resize();

		/* apply staged window updates */
		doupdate();

		/* get a character */
		c = wgetch(statusbar);

		/* handle the character */
		handle_keypress(c, MODE_TASKLIST);

		/* exit */
		if (done)
			break;
		/* reload task list */
		if (reload)
		{
			cur = get_task_by_position(selline);
			if (cur != NULL)
				uuid = strdup(cur->uuid);
			wipe_tasklist();
			reload_tasks();
			task_count();
			redraw = true;
			if (cfg.follow_task)
				set_position_by_uuid(uuid);
			check_free(uuid);
			uuid = NULL;
			tasklist_check_curs_pos();
		}
		/* redraw all windows */
		if (redraw)
		{
			cfg.fieldlengths.project = max_project_length();
			cfg.fieldlengths.description = cols-cfg.fieldlengths.project-1-cfg.fieldlengths.date;
			print_header();
			tasklist_print_task_list();
			tasklist_check_curs_pos();
			touchwin(tasklist);
			touchwin(header);
			touchwin(statusbar);
			wnoutrefresh(tasklist);
			wnoutrefresh(header);
			wnoutrefresh(statusbar);
			doupdate();
		}

		statusbar_timeout();
	}
} /* }}} */