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); }
/** * iris_scheduler_new_full: * @min_threads: The minimum number of threads to allocate * @max_threads: The maximum number of threads to allocate * * Creates a new scheduler with a defined set of thread ratios. * * Return value: the newly created scheduler instance. */ IrisScheduler* iris_scheduler_new_full (guint min_threads, guint max_threads) { IrisScheduler *scheduler; scheduler = iris_scheduler_new (); scheduler->priv->min_threads = min_threads; scheduler->priv->max_threads = max_threads; return scheduler; }