Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
codes
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
38
Issues
38
List
Boards
Labels
Milestones
Merge Requests
8
Merge Requests
8
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
codes
codes
Commits
adcef650
Commit
adcef650
authored
Aug 28, 2015
by
Jonathan Jenkins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rc-stack: support for optimistic debug mode
parent
bad3fec3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
src/util/rc-stack.c
src/util/rc-stack.c
+23
-3
No files found.
src/util/rc-stack.c
View file @
adcef650
...
...
@@ -9,6 +9,12 @@
#include "codes/rc-stack.h"
#include "codes/quicklist.h"
enum
rc_stack_mode
{
RC_NONOPT
,
// not in optimistic mode
RC_OPT
,
// optimistic mode
RC_OPT_DBG
// optimistic *debug* mode (requires special handling)
};
typedef
struct
rc_entry_s
{
tw_stime
time
;
void
*
data
;
...
...
@@ -18,7 +24,7 @@ typedef struct rc_entry_s {
struct
rc_stack
{
int
count
;
int
is_in_optimistic
;
enum
rc_stack_mode
mode
;
struct
qlist_head
head
;
};
...
...
@@ -28,7 +34,16 @@ void rc_stack_create(struct rc_stack **s){
INIT_QLIST_HEAD
(
&
ss
->
head
);
ss
->
count
=
0
;
}
ss
->
is_in_optimistic
=
(
g_tw_synchronization_protocol
==
OPTIMISTIC
);
switch
(
g_tw_synchronization_protocol
)
{
case
OPTIMISTIC
:
ss
->
mode
=
RC_OPT
;
break
;
case
OPTIMISTIC_DEBUG
:
ss
->
mode
=
RC_OPT_DBG
;
break
;
default:
ss
->
mode
=
RC_NONOPT
;
}
*
s
=
ss
;
}
...
...
@@ -42,7 +57,7 @@ void rc_stack_push(
void
*
data
,
void
(
*
free_fn
)(
void
*
),
struct
rc_stack
*
s
){
if
(
s
->
is_in_optimistic
||
free_fn
==
NULL
)
{
if
(
s
->
mode
!=
RC_NONOPT
||
free_fn
==
NULL
)
{
rc_entry
*
ent
=
(
rc_entry
*
)
malloc
(
sizeof
(
*
ent
));
assert
(
ent
);
ent
->
time
=
tw_now
(
lp
);
...
...
@@ -72,6 +87,11 @@ void* rc_stack_pop(struct rc_stack *s){
int
rc_stack_count
(
struct
rc_stack
const
*
s
)
{
return
s
->
count
;
}
void
rc_stack_gc
(
tw_lp
const
*
lp
,
struct
rc_stack
*
s
)
{
// in optimistic debug mode, we can't gc anything, because we'll be rolling
// back to the beginning
if
(
s
->
mode
==
RC_OPT_DBG
)
return
;
struct
qlist_head
*
ent
=
s
->
head
.
next
;
while
(
ent
!=
&
s
->
head
)
{
rc_entry
*
r
=
qlist_entry
(
ent
,
rc_entry
,
ql
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment