~~NOTOC~~ ====== ''hey-guys'': LOL threading ====== ===== Motivation ===== Every forum since dial-up BBSes supports concurrency as a basic concept. This has lead to many LOL constructs referencing concurrency constructs (1). The following is a general proposal for threading constructs in LOLCODE. It also includes some necessary supporting definitions like arrays and a suggestion for strong typing. ===== Example Code ===== Liberally adapted from LLNL's tutorial (2). It incorporates much of the LOL standard (3). HAI CAN HAS STDIO? CAN HAS THREADS? I HAZ A NUM_THREADS ITZ 5 SO IM LIKE HAIWORLD WITH THREADID I HAS A VAR VAR IZ VISIBLE THREADID "SEZ: HELLO WORLD!" VAR IZ 0 ORLY? YA RLY WIN! NO WAI TL;DR KTHX KTHX I HAS MAH THREADS IZ NUM_THREADS MANY OF THREADS I HAS A RC ITZ 0 I HAS A T IM IN YR LOOP VISIBLE "MAKIN THREAD " T " NOW!!" TELL RC IM MAKIN A NEW THREAD ABOUT HAIWORLD ITZ THREADS[T] O NOES INVISIBLE "O NOES BAD THREAD CUZ " RC KTHXBYE UP T!!1 IM OUTTA YR LOOP KTHXBYE ===== Detailed Description ===== === Array Declaration === I HAS MAH IZ <###> MANY OF Note IZ instead of ITZ, as this is an array declaration, not an initial assignment. Other array declarations are fine too === Thread spawning === TELL IM MAKIN A NEW THREAD ABOUT ITZ This creates a new thread, running , and sticks it in . can be an array as in the example above (THREADS[T]). The return code is stuck in . === Thread death === WIN! A successful, happy thread, spawning new macros and lols. (4) TL;DR Dead thread, most likely due to waiting too long (4) (resource contention?) ==== Areas for expansion ==== I MAKED U A COOKIE GIVED U A COOKIE TAKEN A COOKIE FROM DA JAR CAN I HAV COOKIE NOW PLZTHX? Semaphore creation, passing, acceptance, and requests. HEY GUYS WHATS GOIN ON IN THIS THREAD? I'M ALL "" Interthread communication structure. ===== References ===== - [[http://www.encyclopediadramatica.com/Hey_guys_whats_going_on_in_here|Hey guys whats going on in here?]] - [[http://www.llnl.gov/computing/tutorials/pthreads/|LLNL reference on POSIX Threads Programming]] - [[functions]] - [[http://www.encyclopediadramatica.com/Thread|Threads]] --- //Authored by wohali, 2007/05/29 19:33// ===== Comments =====