Hi all, I've got a native thread messaging prototype working using pipes:
http://github.com/phildawes/factor/commits/native-thread-io (@slava: these patches rebase cleanly onto new_gc) The api is the same as in concurrency.messaging except that you call 'spawn-vm' and get a remote-thread handle back. Example: I've included the following example word in native-thread-test: : 3-adder ( -- ) [ receive [ data>> 3 + ] [ sender>> ] bi reply-synchronous t ] loop ; So you can do: ( scratchpad ) USING: native-thread-test concurrency.messaging ; ( scratchpad ) [ 3-adder ] spawn-vm T{ remote-vm-thread f 20 ~native-lock~ 1 } ( scratchpad ) 40 swap send-synchronous 43 <-------------------- witness the awesome power of multi-core! Notes & thoughts: - This isn't compatible with concurrency.distributed because they both implement 'M: thread (serialize)'. At some point we need to work out how this should play nicely with (or fit into) concurrency.distributed - Also my native-thread-test vocab adds support for serializing aliens since they often need to be shared between threads in the same process. 'serialize' may need to be multi-dispatch at some point to address differing thread and alien serialization depending on target. - spawn-vm starts a totally separate vm, which means the new thread has to load and compile missing vocabs. This results in a pause when spawn-vm is called unless you've recently saved your image. - currently factor vms call exit() when they finish, which means any thread exiting takes the whole process down. This usually means spawned threads need to loop, at least for the time being. Also I'm finding that having native threads and coop threads both called 'threads' is a pita when you're trying to describe stuff. Can we call coop threads something else? I think somebody mentioned here that 'fibers' is the current hotness with the java enterprise crowd. Cheers, Phil ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
