MMgc thread safety annotations: Difference between revisions

Line 1: Line 1:
== Basic idea ==
== Basic idea ==


I want to use static analysis to find race conditions in the MMGC_THREADSAFE stuff I'm working on.
I want to use static analysis to find basic MT hazards (mistakes, really) in the MMGC_THREADSAFE stuff I'm working on.


So I've started putting annotations on each member function and each member variable of <code>class MMgc::GC</code>.  Like this:
So I've started putting annotations on each member function and each member variable of <code>class MMgc::GC</code>.  Like this:
Line 36: Line 36:
  }
  }
  }
  }
As it turns out, this is helpful even without static analysis.  These policies are part of the contract for every method and every variable.  They should definitely be documented, at least!


For member variables, the <code>@access</code> restriction applies to any thread trying to read or write the variable.  For member functions, it applies to the calling thread.
For member variables, the <code>@access</code> restriction applies to any thread trying to read or write the variable.  For member functions, it applies to the calling thread.
638

edits