Uploaded image for project: 'Metadata Aggregator'
  1. Metadata Aggregator
  2. MDA-207 review MDA API
  3. MDA-242

API Review: thread safety and synchronization

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Resolved
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 0.9.2
    • Fix Version/s: 0.10.0
    • Component/s: None
    • Labels:
      None

      Description

      Use of @ThreadSafe and synchronized is somewhat sparse and inconsistent. @ThreadSafeAfterInit is never used.

      I think we should document the assumption that:

      • Components are constructed and initialized on a single thread.
        • This implies that they need not be generally @ThreadSafe and there is no need to mark either constructors or property setters as synchronized.
      • Components are @ThreadSafeAfterInit
        • In some rare cases, this might require that property getters are synchronized, but I can't think of an instance where this would need to be the case in practice.
      • Components such as stages need to be reentrant: their execute method may be called simultaneously from multiple threads (e.g., in parallel pipelines).
        • This means that fields need to be either inherently @ThreadSafe, or synchronized appropriately. Synchronizing execute should be the last resort.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ian@iay.org.uk Ian Young
              Reporter:
              ian@iay.org.uk Ian Young
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: