Skip to content

Deprecate Mutex.onLock for removal #2794

Closed
@qwwdfsad

Description

Apart from regular locking methods, coroutine's Mutex provides a selectable onLock method.

Selectable locking was added prior to version 1.0.0 for the sake of consistency and now adds more maintenance and public API burden than actual utility:

  • It cannot be used along with owner-based locking
  • It cannot be reliably aligned with similar synchronous primitives API, e.g. Semaphore
  • It obfuscated an API of Mutex-based primitives, such as ReadWriteMutex, where its read counter-part is cannot provide any selectable primitives
  • Its implementation, in a nutshell, relies on a code-heavy DCSS primitive, that implicitly increases the size of all Android applications that use Mutex in any way

As far as we know, it's neither used in our own coroutines-heavy internal codebases nor in any open-source projects and our research shows that it has no sane practical uses.

Thus the proposal is to deprecate it for removal in 1.6.0, deprecate with ERROR in 1.7.0 and, after further investigation, either remove it completely in 1.8.0 or provide a non-linearizable stub implementation and maintain it forever

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions