2 Copyright (C) 2006-2008, The Perl Foundation.
7 src/pmc/parrotrunningthread.pmc -- Represents a running Parrot Thread.
11 This type represents a running parrot thread.
13 It provides the following methods:
18 Note that a running thread object becomes invalid when a thread
19 finishes while detached or joined. Further operations on the
20 object may have unexpected behavior, such as manipulating an
31 #include "parrot/parrot.h"
32 #include "parrot/embed.h"
34 pmclass ParrotRunningThread no_ro {
40 Create a new, invalid handle to a running thread.
47 PMC_int_val(SELF) = -1;
52 =item C<void init_pmc(PMC *tid)>
54 Create a new running thread referring to the thread with
55 the Thread ID specified in C<tid>.
61 VTABLE void init_pmc(PMC *tid) {
62 PMC_int_val(SELF) = VTABLE_get_integer(INTERP, tid);
67 =item C<INTVAL get_integer()>
69 Return the thread ID of this thread.
75 VTABLE INTVAL get_integer() {
76 return PMC_int_val(SELF);
81 =item C<void set_integer_native(INTVAL new_tid)>
83 Change the thread ID we refer to to C<new_tid>.
87 VTABLE void set_integer_native(INTVAL new_tid) {
88 PMC_int_val(SELF) = new_tid;
92 =item C<METHOD join()>
94 Join the thread, returning whatever its main method returns.
100 PMC *ret = pt_thread_join(INTERP, PMC_int_val(SELF));
102 /* invalidate self */
103 PMC_int_val(SELF) = -1;
110 =item C<METHOD detach()>
112 Detach the thread so it cannot be joined and will free its
113 resources immediatelly when it exits.
120 pt_thread_detach(PMC_int_val(SELF));
125 =item C<METHOD kill()>
127 Terminate a running thread.
134 pt_thread_kill(PMC_int_val(SELF));
149 * c-file-style: "parrot"
151 * vim: expandtab shiftwidth=4: