~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transactions.py

  • Committer: Robert Collins
  • Date: 2006-04-28 05:54:33 UTC
  • mto: (1697.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1701.
  • Revision ID: robertc@robertcollins.net-20060428055433-be86bc92d5efd816
Document what the break-lock commands should be like

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005 by Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
18
"""This module provides a transactional facility.
19
19
 
30
30
write ordering approach we use for consistency 'dirty' is a misleading term.
31
31
A dirty object is one we have modified.
32
32
 
33
 
Both read and write transactions *may* flush unchanged objects out of
34
 
memory, unless they are marked as 'precious' which indicates that
 
33
Both read and write transactions *may* flush unchanged objects out of 
 
34
memory, unless they are marked as 'precious' which indicates that 
35
35
repeated reads cannot be obtained if the object is ejected, or that
36
36
the object is an expensive one for obtaining.
37
37
"""
59
59
 
60
60
    def is_clean(self, an_object):
61
61
        """Return True if an_object is clean."""
62
 
        return (an_object in self._clean_objects)
 
62
        return an_object in self._clean_objects
63
63
 
64
64
    def register_clean(self, an_object, precious=False):
65
65
        """Register an_object as being clean.
66
 
 
 
66
        
67
67
        If the precious hint is True, the object will not
68
68
        be ejected from the object identity map ever.
69
69
        """
79
79
 
80
80
    def set_cache_size(self, size):
81
81
        """Set a new cache size."""
82
 
        if size < -1:
83
 
            raise ValueError(size)
 
82
        assert -1 <= size
84
83
        self._limit = size
85
84
        self._trim()
86
85
 
135
134
 
136
135
    def is_dirty(self, an_object):
137
136
        """Return True if an_object is dirty."""
138
 
        return (an_object in self._dirty_objects)
 
137
        return an_object in self._dirty_objects
139
138
 
140
139
    def register_dirty(self, an_object):
141
140
        """Register an_object as being dirty.
142
 
 
 
141
        
143
142
        Dirty objects are not ejected from the identity map
144
143
        until the transaction finishes and get informed
145
144
        when the transaction finishes.
154
153
        """Write transactions allow writes."""
155
154
        return True
156
155
 
157
 
 
 
156
        
158
157
class PassThroughTransaction(object):
159
158
    """A pass through transaction
160
 
 
 
159
    
161
160
    - nothing is cached.
162
161
    - nothing ever gets into the identity map.
163
162
    """
176
175
 
177
176
    def register_clean(self, an_object, precious=False):
178
177
        """Register an_object as being clean.
179
 
 
 
178
        
180
179
        Note that precious is only a hint, and PassThroughTransaction
181
180
        ignores it.
182
181
        """
183
182
 
184
183
    def register_dirty(self, an_object):
185
184
        """Register an_object as being dirty.
186
 
 
 
185
        
187
186
        Dirty objects get informed
188
187
        when the transaction finishes.
189
188
        """