Starting release 0.7.0
[parrot.git] / src / stm / stm_waitlist.h
blobeafc41224b200f2a9491a1c79820c1b40752e3ba
1 /*
2 * $Id$
3 * Copyright (C) 2006-2007, The Perl Foundation.
4 */
6 #ifndef PARROT_STM_WAITLIST_H_GUARD
7 #define PARROT_STM_WAITLIST_H_GUARD
9 #include "parrot/atomic.h"
11 #define WAITLIST_DEBUG 0
13 struct STM_tx_log;
15 typedef struct STM_tx_log STM_tx_log;
17 typedef struct waitlist_entry {
18 /* next entry in the waitlist */
19 struct waitlist_entry *next;
20 /* the thread that will need to be signaled to wake it up */
21 struct waitlist_thread_data *thread;
22 /* the head of this waitlist */
23 struct waitlist_head *head;
24 } waitlist_entry;
26 typedef struct waitlist_head {
27 Parrot_atomic_pointer first;
28 Parrot_mutex remove_mutex;
29 } waitlist_head;
31 typedef struct waitlist_thread_data {
32 /* this mutex must be locked before setting signaled_p to true */
33 Parrot_mutex signal_mutex;
35 /* this condition variable is signalled after setting signaled_p
36 * to true.
38 Parrot_cond *signal_cond;
40 /* this is set to true if this thread has been signaled; should
41 * remain false otherwise.
43 int signaled_p;
45 /* pointers to all the waitlist entries */
46 struct waitlist_entry **entries;
47 size_t entry_count;
48 size_t used_entries;
49 #if WAITLIST_DEBUG
50 Interp *interp;
51 #endif
52 } waitlist_thread_data;
54 typedef struct waitlist_head STM_waitlist;
56 /* HEADERIZER BEGIN: src/stm/waitlist.c */
57 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
59 PARROT_CANNOT_RETURN_NULL
60 STM_tx_log * Parrot_STM_tx_log_get(PARROT_INTERP)
61 __attribute__nonnull__(1);
63 void Parrot_STM_waitlist_add_self(PARROT_INTERP,
64 ARGMOD(STM_waitlist *waitlist))
65 __attribute__nonnull__(1)
66 __attribute__nonnull__(2)
67 FUNC_MODIFIES(*waitlist);
69 void Parrot_STM_waitlist_destroy_thread(PARROT_INTERP)
70 __attribute__nonnull__(1);
72 void Parrot_STM_waitlist_init(PARROT_INTERP, ARGMOD(STM_waitlist *waitlist))
73 __attribute__nonnull__(1)
74 __attribute__nonnull__(2)
75 FUNC_MODIFIES(*waitlist);
77 void Parrot_STM_waitlist_remove_all(PARROT_INTERP)
78 __attribute__nonnull__(1);
80 void Parrot_STM_waitlist_signal(PARROT_INTERP,
81 ARGMOD(STM_waitlist *waitlist))
82 __attribute__nonnull__(1)
83 __attribute__nonnull__(2)
84 FUNC_MODIFIES(*waitlist);
86 void Parrot_STM_waitlist_wait(PARROT_INTERP)
87 __attribute__nonnull__(1);
89 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
90 /* HEADERIZER END: src/stm/waitlist.c */
92 #endif /* PARROT_STM_WAITLIST_H_GUARD */
95 * Local variables:
96 * c-file-style: "parrot"
97 * End:
98 * vim: expandtab shiftwidth=4: