Uploaded image for project: 'Realm Core'
  1. Realm Core
  2. RCORE-1296

[C-API] Align notification/callback registration mechanism in the C-API

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      Describe your problem or use case

      There are still different ways to unregister various callback mechanism throughout the C-API.

      Previously realm_add_realm_changed_callback and realm_add_schema_changed_callback have been updated in https://github.com/realm/realm-core/issues/5217 to follow the C-API managed approach of returning a token object that could be released through realm_release to unregister the callbacks.

      There are still numerous use cases where the C-API has both a x_register and a x_unregister method, which is annoying as we cannot just manage all C-API allocated resources in a common way.

      Identified APIs:
      https://github.com/realm/realm-core/blob/master/src/realm.h#L3853
      https://github.com/realm/realm-core/blob/master/src/realm.h#L3938
      https://github.com/realm/realm-core/blob/master/src/realm.h#L3961

      Describe the solution you'd like

      Would be nice if all callback registrations could just follow the same pattern of releasing resources by calling realm_release with a token object issued when registrating the callback. Since all these callbacks are usually not on the hot path, I don't see an issue in the additional allocation.

            Assignee:
            nicola.cabiddu@mongodb.com Nicola Cabiddu
            Reporter:
            claus.rorbech@mongodb.com Claus Rørbech (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: