''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 <name> IZ <###> MANY OF <TYPE>Note IZ instead of ITZ, as this is an array declaration, not an initial assignment. Other array declarations are fine too
Thread spawning
TELL <var_1> IM MAKIN A NEW THREAD ABOUT <function> ITZ <var_2>This creates a new thread, running <function>, and sticks it in <var_2>. <var_2> can be an array as in the example above (THREADS[T]). The return code is stuck in <var_1>.
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 "<message to pass>"
Interthread communication structure.
References
— Authored by wohali, 2007/05/29 19:33