Perl 6
SMOP REFERENCE and RELEASE Policy: Revision 3

Even if not all object systems use reference counting garbage collection, the possible existance of some object system that does, requires us to implement the mechanisms that make it possible. That is why, besides MESSAGE, two other functions are defined in the responder interface lowlevel type. The REFERENCE and RELEASE functions. This functions are supposed to be the hooks for implementing a refcount garbage collector.

Who owns the object?

This is the most important question in the matter of when to call REFERENCE and when to call RELEASE. And a simple policy shall describe this decision:

  • When an object is created, it's owned by the code who called the method that creates it.
  • Passing an object to a capture implies transfering the ownership of the object.
  • A call to REFERENCE defines an additional owner to the object.
  • A call to RELEASE implies that this owner no longer wants the object.

What does it mean?

Simple as: every time you pass an object as an argument to a call, the object will belong to the called method and you will no longer be allowed to use the object. Unless, of course, you pass it while defining a new REFERENCE. A little code to illustrate:

SMOP__Object* foo = smop_lowlevel_alloc(sizeof(SMOP__Object));
// the object is owned by the current code.

// if you want to be able to use the object after passing it to
// a capture, you must reference it.
SMOP__Object* cap = SMOP__NATIVE__capture_create(intr, SMOP_REFERENCE(intr,foo), NULL, NULL);

// but if you won't need the object in this code anymore, you can
// save a little effort and just do.
SMOP__Object* cap2 = SMOP__NATIVE__capture_create(intr, foo, NULL, NULL);

// but Objects that you own must be released when you don't need them
// anymore.
SMOP_RELEASE(intr, cap);
SMOP_RELEASE(intr, cap2);


Upload Files

Click "Browse" to find the file you want to upload. When you click "Upload file" your file will be uploaded and added to the list of attachments for this page.

Maximum file size: 50MB

 
 
 
File Name Author Date Uploaded Size

Save Page As

Enter a meaningful and distinctive title for your page.

Page Title:

Tip: You'll be able to find this page later by using the title you choose.

Page Already Exists

There is already a page named XXX. Would you like to:

Save with a different name:

Save the page with the name "XXX"

Append your text to the bottom of the existing page named: "XXX"

Upload Files

Click "Browse" to find the file you want to upload. When you click "Add file" this file will be added to the list of attachments for this page, and uploaded when you save the page.

 
 
 
Add Tags

Enter a tag and click "Add tag". The tag will be saved when you save the page.

Tag: 

Suggestions: