Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Allow registering Ruby callbacks for V8 objects. #387

Open
wants to merge 5 commits into
base: upgrade-to-v8-4.5
Choose a base branch
from

Commits on Aug 28, 2015

  1. Allow registering Ruby callbacks for V8 objects.

    This allows Ruby code to listen directly for when V8 object is garbage
    collected. This is done with the `__DefineFinalizer__` method which can
    be invoked on any handle. E.g.
    
      v8_object.__DefineFinalizer__(method_that_generates_callable)
    
    Just like in Ruby, care should be taken to ensure that the finalizer
    does not reference the V8 object at all, otherwise, it might prevent it
    from being garbage collected. The later, once v8_object has been gc'd,
    the finalizer will be enqueued into an internal data structure that can
    be accessed via the isolate's `__EachV8Finalizer`
    
      isolate.__EachV8Finalizer__ do |finalizer|
        finalizer.call()
      end
    
    There was a question of whether to follow the strict V8 API for this,
    and expose the `SetWeak` method, but this would mean actually making a
    handle weak, which is fine, but then we would have to add a mechanism
    to capture a strong reference from any reference which we don't have.
    
    We may want to revisit this at some later date.
    cowboyd committed Aug 28, 2015
    Configuration menu
    Copy the full SHA
    750e6b4 View commit details
    Browse the repository at this point in the history
  2. bump the finalizer to allocate 10 objects.

    That will ensure that at least one object triggers finalization.
    cowboyd committed Aug 28, 2015
    Configuration menu
    Copy the full SHA
    f902729 View commit details
    Browse the repository at this point in the history
  3. Merge branch 'upgrade-to-v8-4.5' into 4.5/add-ruby-finalizers-to-v8-o…

    …bjects
    
    Conflicts:
    	ext/v8/isolate.h
    cowboyd committed Aug 28, 2015
    Configuration menu
    Copy the full SHA
    918c0c9 View commit details
    Browse the repository at this point in the history

Commits on Sep 1, 2015

  1. Fully implement Handle::SetWeak

    This implementation hues very closesly to the actual V8 API, so is more
    desirable. It also adds the ability to capture a handle to an existing
    object.
    cowboyd committed Sep 1, 2015
    Configuration menu
    Copy the full SHA
    57271fd View commit details
    Browse the repository at this point in the history

Commits on Sep 2, 2015

  1. Configuration menu
    Copy the full SHA
    e6d67c7 View commit details
    Browse the repository at this point in the history