Commits

Remi Meier committed ac4ab9e

stm: add thread.should_commit()

Comments (0)

Files changed (5)

pypy/module/thread/__init__.py

         'is_atomic':              'atomic.is_atomic',
         'at_commit':              'stm.at_commit',
         'run_commit':             'stm.run_commit',
+        'should_commit':          'stm.should_commit',
     }
 
     def __init__(self, space, *args):

pypy/module/thread/stm.py

                 ec._at_commit_cbs = []
                 if we_are_translated():
                     rstm.decrement_atomic()
+
+def should_commit(space):
+    from pypy.rlib import rstm
+    rstm.should_commit()

pypy/rlib/rstm.py

     return we_are_translated() and (
         stmgcintf.StmOperations.should_break_transaction())
 
+def should_commit():
+    if we_are_translated():
+        stmgcintf.StmOperations.should_commit()
+
 def set_transaction_length(length):
     stmgcintf.StmOperations.set_transaction_length(length)
 

pypy/translator/stm/src_stm/rpyintf.c

   return d->list_of_read_objects.size >= d->reads_size_limit;
 }
 
+void stm_should_commit(void)
+{
+  struct tx_descriptor *d = thread_descriptor;
+  d->reads_size_limit_nonatomic = 0;
+  update_reads_size_limit(d);
+}
+
 void stm_set_transaction_length(long length_max)
 {
   struct tx_descriptor *d = thread_descriptor;

pypy/translator/stm/stmgcintf.py

     set_transaction_length = smexternal('stm_set_transaction_length',
                                         [lltype.Signed], lltype.Void)
 
+    # this instructs should_break_transaction() to return True
+    # used to "soft"-end a transaction (without creating a new inevitable one)
+    should_commit = smexternal('stm_should_commit', [], lltype.Void)
+
     # for testing
     abort_and_retry  = smexternal('stm_abort_and_retry', [], lltype.Void)