Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
G
GLib
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 926
    • Issues 926
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 60
    • Merge Requests 60
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • GNOME
  • GLib
  • Merge Requests
  • !54

Merged
Opened Jun 04, 2018 by Emmanuele Bassi@ebassi👣Maintainer

Reference counting types

  • Overview 25
  • Commits 6
  • Pipelines 6
  • Changes 13

GLib uses reference counting semantics in basically all of its container data types, but every implementation has its own bespoke solution. Additionally, reference counting is pretty much the common memory management and garbage collection policy for the whole of the G* platform when it comes to complex data types.

GLib should offer reference counting types and functions to ensure that all implementations conform to similar semantics, especially with regards to saturation and potential integer overflow and wrapping.

In order to cover all possible bases, we have two distinct reference counting types and API:

  • grefcount, which provides a simple reference counter
  • gatomicrefcount, which provides a thread-safe reference counter with atomic semantics

Both reference counters share the C int space, with grefcount using the negative range, and gatomicrefcount using the positive range; this allows us to verify that we're not going to mix the two, and that we can use the atomic integer operations.

Both reference counters check for saturation – i.e. when the counter reaches the maximum allowed value.

Issues: #561 (closed), #315 (closed)

Edited Jun 04, 2018 by Emmanuele Bassi
Assignee
Assign to
Reviewer
Request review from
2.58
Milestone
2.58 (Past due)
Assign milestone
Time tracking
Reference: GNOME/glib!54
Source branch: refcount-types

Revert this merge request

This will create a new commit in order to revert the existing changes.

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.

Cherry-pick this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.