thread model ------------ simple message passing: static const string[] typedef Message = struct( int a; float b; const string static* description; readonly static* status; string static* log; ); thread () work(ThreadQueue[Message own*]* q, Message own* msg) { // work with msg // we can access "own" pointers as normal msg.a = 1; // we can also access pointers to static constant data // (const data is assumed to not change) print(description); // if we want to access readonly pointers, we need exclusive access // TODO //print(status); // Or we can use the atomic keyword print(atomic(status)); // with normal pointers we also need exclusive access // TODO //print(log); q.push(msg); } int main(count argc, string[argc] argv) { ThreadQueue[Message own *] q(); // equivalent to ThreadQueue q; q.init(); for (int i : [0..9]) { Message *own msg = Message.new(1, 2.34); // all pointers in (q, msg) must either be "own" or "static" thread(work, (q, msg)); // msg may no longer be used! } while (condition) { for (Message own *msg } }