Esempio n. 1
0
static void
main_context1 (void)
{
	IrisScheduler *scheduler;
	IrisReceiver  *receiver;
	IrisPort      *port;
	IrisMessage   *message;
	gint           counter = 0;
	gint           i;

	// Use basic scheduler
	scheduler = iris_scheduler_new ();
	g_assert (scheduler != NULL);
	port = iris_port_new ();
	g_assert (port != NULL);
	receiver = iris_arbiter_receive (scheduler, port, main_context1_cb, &counter, NULL);
	g_assert (receiver != NULL);

	for (i = 0; i < 100; i++) {
		message = iris_message_new (1);
		iris_port_post (port, message);
	}

	// THIS IS A RACE CONDITION. But seems to be long enough for my
	// testing so far. Of course, its the entire reason we will be
	// making IrisTask soon.
	g_usleep (G_USEC_PER_SEC / 4);

	g_assert (counter == 100);
}
Esempio n. 2
0
static IrisProgressWatch *
iris_progress_monitor_add_watch_internal (IrisProgressMonitor             *progress_monitor,
                                          IrisTask                        *task,
                                          const gchar                     *title,
                                          IrisProgressGroup               *group)
{
	IrisProgressMonitorInterface *iface;
	IrisProgressWatch *watch;

	watch = g_slice_new0 (IrisProgressWatch);
	watch->monitor = progress_monitor;
	watch->port = iris_port_new ();

	watch->progress_mode = iris_task_get_progress_mode (task);

	if (group != NULL) {
		iris_progress_group_ref (group);
		watch->group = group;

		group->watch_list = g_list_prepend (group->watch_list, watch);

		if (watch->progress_mode == IRIS_PROGRESS_ACTIVITY_ONLY)
			group->progress_mode = IRIS_PROGRESS_ACTIVITY_ONLY;
	}

	watch->title = g_strdup (title);

	watch->task = task;

	iface = IRIS_PROGRESS_MONITOR_GET_INTERFACE(progress_monitor);
	iface->add_watch (progress_monitor, watch);

	return watch;
}