Beispiel #1
0
int main()
{
	/* Initialize the fiber library */
	initFibers();
	
	/* Go fibers! */
	spawnFiber( &fiber1 );
	spawnFiber( &fibonacchi );
	spawnFiber( &squares );

	/* Since these are nonpre-emptive, we must allow them to run */
	waitForAllFibers();
	
	/* The program quits */
	return 0;
}
Beispiel #2
0
ctr_object* ctr_fiber_spawn(ctr_object* myself, ctr_argument* argumentList) {
  ctr_object* fiberObj = ctr_fiber_create(myself, NULL);
  ctr_object* blk = argumentList->object;
  if(blk == NULL || blk->info.type != CTR_OBJECT_TYPE_OTBLOCK) {CtrStdFlow = ctr_build_string_from_cstring("Fiber's spawning requires a block."); return myself;}
  int fiber = spawnFiber(argumentList->object);
  ctr_internal_object_add_property(fiberObj, ctr_build_string_from_cstring("fiberId"), ctr_build_number_from_float(fiber), CTR_CATEGORY_PRIVATE_PROPERTY);
  return fiberObj;
}