/
stm.ops
127 lines (83 loc) · 2.32 KB
/
stm.ops
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* $Id$
* Copyright (C) 2006, The Perl Foundation.
*/
#include "parrot/stm/backend.h"
=pod
=head1 NAME
stm.ops -- Software transactional memory related ops
=head1 DESCRIPTION
Operations for software transactional memory. Includes all transaction
manipulating flow-control, actual transacted data manipulation occurs
through STMRef/STMVar PMCs.
=head2 Parrot STM operations
=over 4
=cut
VERSION = PARROT_VERSION;
=item B<stm_start>()
Start a new transaction.
=cut
inline op stm_start() {
Parrot_STM_start_transaction(interp);
goto NEXT();
}
=item B<stm_validate>(label INT)
If the current transaction is invalid jump to $1; otherwise,
excecution continues normally.
If there is no active transaction, execution continues normally.
=cut
inline op stm_validate(labelconst INT) {
if (!Parrot_STM_validate(interp))
goto OFFSET($1);
goto NEXT();
}
=item B<stm_commit>(labelconst INT)
Commits the most recently opened transaction. Jumps to $1 if the
commit fails. (If the outer transaction is invalid, this should succeed
always.)
If stm_commit jumps to $1, then the transaction will have been aborted.
=cut
inline op stm_commit(labelconst INT) {
if (!Parrot_STM_commit(interp))
goto OFFSET($1); /* retry */
goto NEXT();
}
=item B<stm_wait>(label INT)
Does what stm_wait does, but if the outer transaction is invalid after
waiting or after the inner transaction is aborted, jumps to $1.
(The jump is needed because otherwise the inner transaction may never succeed
because the outer transaction constrains it to not see new values.)
=cut
inline op stm_wait(labelconst INT) {
Parrot_STM_wait(interp);
if (!Parrot_STM_validate(interp))
goto OFFSET($1);
goto NEXT();
}
=item B<stm_abort>()
Aborts the most recently opened transaction.
=cut
inline op stm_abort() {
Parrot_STM_abort(interp);
goto NEXT();
}
=item B<stm_depth>(out INT)
Writes the number transactions active in this thread into $1.
=cut
inline op stm_depth(out INT) {
$1 = Parrot_STM_transaction_depth(interp);
goto NEXT();
}
=back
=head1 COPYRIGHT
Copyright 2006 The Perl Foundation.
=head1 LICENSE
This program is free software. It is subject to the same license
as the Parrot interpreter itself.
=cut
/*
* Local variables:
* c-file-style: "parrot"
* End:
* vim: expandtab shiftwidth=4:
*/