forked from DeuceSTM/DeuceSTM
/
Context.java
71 lines (61 loc) · 2.69 KB
/
Context.java
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
/*
* @(#)Context.java 05/01/2008
*
* Copyright 2008 GigaSpaces Technologies Inc.
*/
package org.deuce.transaction;
import org.deuce.objectweb.asm.Type;
import org.deuce.transform.Exclude;
/**
* All the STM implementations should implement this interface.
* Using the -Dorg.deuce.transaction.contextClass property one can
* switch between the different implementations.
*
* @author Guy Korland
* @since 1.0
*/
@Exclude
public interface Context
{
final static public Type CONTEXT_TYPE = Type.getType( Context.class);
final static public String CONTEXT_INTERNAL = Type.getInternalName(Context.class);
final static public String CONTEXT_DESC = Type.getDescriptor(Context.class);
/**
* Called before the transaction was started
* @param atomicBlockId a unique id for atomic block
* @param metainf a meta information on the current atomic block.
*/
void init(int atomicBlockId, String metainf);
/**
* Called on commit
* @return <code>true</code> on success
*/
boolean commit();
/**
* Called on rollback, rollback might be called more than once in a row.
* But, can't be called after {@link #commit()} without an {@link #init(int, String)} call in between.
*/
void rollback();
/* Methods called on Read/Write event */
void beforeReadAccess( Object obj, long field, int advice);
Object onReadAccess( Object obj, Object value, long field, int advice);
boolean onReadAccess( Object obj, boolean value, long field, int advice);
byte onReadAccess( Object obj, byte value, long field, int advice);
char onReadAccess( Object obj, char value, long field, int advice);
short onReadAccess( Object obj, short value, long field, int advice);
int onReadAccess( Object obj, int value, long field, int advice);
long onReadAccess( Object obj, long value, long field, int advice);
float onReadAccess( Object obj, float value, long field, int advice);
double onReadAccess( Object obj, double value, long field, int advice);
void onWriteAccess( Object obj, Object value, long field, int advice);
void onWriteAccess( Object obj, boolean value, long field, int advice);
void onWriteAccess( Object obj, byte value, long field, int advice);
void onWriteAccess( Object obj, char value, long field, int advice);
void onWriteAccess( Object obj, short value, long field, int advice);
void onWriteAccess( Object obj, int value, long field, int advice);
void onWriteAccess( Object obj, long value, long field, int advice);
void onWriteAccess( Object obj, float value, long field, int advice);
void onWriteAccess( Object obj, double value, long field, int advice);
/** Called before entering an irrevocable block*/
void onIrrevocableAccess();
}