So here's the problem: you can wrap a generator in a chip to create source. Easy!
But you cannot run a pipeline inside a generator. This is because a generator is a function closure, which therefore uses the machine stack for the return address, and fthreads do service requests by simply returning control to the scheduler. So a pipeline inside a generator or other function would just return control on the first service call, which would probably be a spawn_fthread. Nothing would happen even if the typing was correct. I am now going to solve this problem, probably in stages. The first stage will allow you to create a scheduler object, and spawn fibres to be run by that scheduler. Such a scheduler object is distinct from the master scheduler. So you cannot in general use channels which span between schedulers. However, if you do, interesting things happen. Remember that fthreads suspended waiting on channel I/O are owned by the channel. No scheduler knows about them. So if you write on a channel from a fthread running on the main scheduler, then read on a subsidiary scheduler, the writer fthread is now lifted to the subsidiary scheduler. Now, you may ask: how does Felix run procedures inside functions now?? ANSWER: It use a supreme hack! Of course! It calls a MICRO scheduler: void run(::flx::rtl::con_t *p) { while(p) { try { p=p->resume(); } catch (::flx::rtl::con_t *x) { p = x; } } } This just ignores service requests. It handles procedure calls and returns but nothing else. If we replaced this with a subsidiary scheduler we could do channel I/O. There are consequences! The function cannot return until all the active threads have run. Remember this doesn't just mean ones spawned by this function. It also includes any sucked in from the master layer by using any bridging channels. All hell will break loose if you have a channel in global scope and use that, because that will probably suck in the whole mainline :) [Actually I have not thought deeply about this] Note also my first cut will only do synchronous I/O. You cannot do async I/O (reading sockets for example). -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Keep yourself connected to Go Parallel: TUNE You got it built. Now make it sing. Tune shows you how. http://goparallel.sourceforge.net _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language