[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    Resource(3X) manual page Table of Contents

Name

Resource - shared data object

Synopsis

#include <ivplus/resource.h>

Description

Resource is a class that provides a simple form of reference counting for shared objects. Every resource has a reference count that is initially set to zero and must be explicitly incremented through a call to Reference. A resource should not be deleted like other objects; instead, the static member function unref() should be used to unreference the object.

When a resource is unreferenced, the reference count is decremented unless it is already zero. If the count is zero and defer is true, the object is destroyed.

Resource is an abstract base class.

Class Hierarchy

Resource

Constructors

Resource()

Creates a new Resource object with its reference count set to zero. Since Resource is an abstract base class, this constructor is protected.

Public Operations

virtual void cleanup()

This operation is called by the unref_deferred() or unref() operations to tell the resource that it is pending destruction and should take appropriate actions.

static boolean defer(boolean)

When set to true, this postpones the deletion of a Resource with a reference count of 0 until flush() is called. If set to false, Resources with a reference count of 0 will be deleted immediately.

static void flush()

Performs the deletion on any resources that have been deferred.

virtual void ref() const

virtual void Reference() const

Increment the resource’s reference count.

static void ref(const Resource* r)

Increments the resource’s reference count. If r is nil, the ref() operation performs a no-op.

virtual void unref() const

virtual void Unreference() const

Decrement the resource’s reference count. If the reference count is zero, call the delete() operation.

static void unref(Resource* r)

Decrements the resource’s reference count. If r is nil, the ref() operation performs a no-op. If the reference count is zero, call the delete() operation.

virtual void unref_deferred() const

static void unref_deferred(const Resource*)

Use in conjunction with the defer() operation to defer deleting resources until the flush() operation is called.

X Resources

None.

Examples

No example for this abstract base class.

Files


resource.h

See Also

Subject(3X) .


Table of Contents