Skip to content

Refactor Transaction<T> to support cross-type STM variables by removing generic parameter #6

@engineering87

Description

@engineering87

Description

Currently, the Transaction<T> class is generic and constrained to handle STM variables of a single type T per transaction. This design limits the ability to perform atomic operations across multiple STM variables of different types within the same transaction.

Problem

  • Transactions cannot span variables of different types simultaneously (e.g., mixing int and string STM variables in one atomic operation).
  • This restricts practical use cases where shared state is composed of heterogeneous types.

Proposed solution

  • Remove the generic parameter <T> from the Transaction class, making it non-generic.
  • Adapt the internal data structures to hold STM variables of different types, possibly using a non-generic ISTMVariable interface or an object-based approach.
  • Implement safe casting and type checking during read/write operations to maintain type safety at runtime.

Benefits

  • Enables atomic transactions involving multiple STM variables of different types.
  • Increases flexibility and expressiveness of STM operations.
  • Aligns with common STM usage patterns where shared state is heterogeneous.

Considerations

  • May introduce some overhead due to boxing/unboxing and runtime casts.
  • Requires thorough testing to ensure type safety and performance are not adversely affected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions