Class: OS::Mac::FFI::CoreFoundation::ReleasePool Private

Inherits:
Object
  • Object
show all
Defined in:
os/mac/ffi/core_foundation.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Tracks Core Foundation objects so they can be released deterministically.

Instance Method Summary collapse

Constructor Details

#initializevoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



27
28
29
# File 'os/mac/ffi/core_foundation.rb', line 27

def initialize
  @pointers = T.let([], T::Array[Fiddle::Pointer])
end

Instance Method Details

#drainvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



40
41
42
43
# File 'os/mac/ffi/core_foundation.rb', line 40

def drain
  @pointers.reverse_each { |ptr| CoreFoundation.release(ptr) }
  @pointers.clear
end

#track(ptr) ⇒ Fiddle::Pointer

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Registers an owned Core Foundation object for release when the pool is drained and returns it unchanged.

Parameters:

  • ptr (Fiddle::Pointer)

Returns:

  • (Fiddle::Pointer)


34
35
36
37
# File 'os/mac/ffi/core_foundation.rb', line 34

def track(ptr)
  @pointers << ptr unless ptr.null?
  ptr
end