Next: , Up: Complex Referable Data Type Example


3.4.2.1 Referable Queue C Definition

Consider some definition for the actual queue data structure (not of interest for here example):

struct data {
};

Objects of type queue will need to implement the reference tracking mechanism. Feature the reference count and the list of objects holding references to the queues themselves - a pointer set, not detailed here:

See How References Are Tracked.

See Detecting Cycles.

struct node {
    unsigned call;
    void *pset;
};

See Libraries.

Put these together for the queue object definition:

struct this_type {
    struct data data;
    struct node node;
};

Add the required struct x1f4_nodelink_type field for the complete definition:

See struct x1f4_nodelink_type.

See Reference Tracking Mechanics.

struct this_type {
    struct data data;
    struct node node;
    struct x1f4_nodelink_type link;
};