Beispiel #1
0
Datei: main.c Projekt: yumm007/C
void *pth_fun(void *ind)
{
	int i, j, ret;
	job_des job;

	char arg[1024];
	int job_arr[TIM_MAX];

	for (i = 1, j = 0; i < TIM_MAX; i++) {
		job.sec = i;
		job.rep_time = i;
		job.fun = fun1;
		sprintf(arg, "repert job in thread %d: job number %d wait %d's", (int)ind, i, i);
		job.arg = arg;
		job.arg_size = strlen((char *)job.arg) + 1;
		if ((ret = at_add_job(&job)) >= 0) {
			job_arr[i] = ret;
			j++;
		}
	}

	while (j) {
		sleep(1);
		for (i = 1; i< TIM_MAX; i++)
			if (at_get_sta(job_arr[i]) == 8) {
				at_wait_job(job_arr[i]);
				j--;
			}
	}

	pthread_exit(NULL);
}
Beispiel #2
0
Datei: at_new.c Projekt: piki/gat
static gboolean at_commit_job(at_druid_info *info) {
  const char *t;
  guint month, day, year;
  at_job_t *job = NULL;
  t = EGET(command);
  if (!t || !*t) return FALSE;
  job = g_new(at_job_t, 1);
  job->cmd = strdup(t);
  job->id = job->queue = job->when = NULL;

  gtk_calendar_get_date(GTK_CALENDAR(info->cal), &year, &month, &day);
  job->when = g_strdup_printf("%02d%02d %02d/%02d/%04d",
    SGET(hour), SGET(minute), month+1, day, year);

  gtk_widget_destroy(info->win);
  at_add_job(job);
  return TRUE;
}