Previous: Introduction Up: Processor Objects Next: Defining Processor Object Types

Declaring Processor Object Types

A processor object type is declared when a class or structure declaration is modified by the keyword global. The processor object class specifies the interface to objects of that type. Public member functions and data may be accessed by anyone with a global pointer to that processor object.

Processor object types can be inherited. As with C++ objects, private and protected members are only accessible from member functions of that processor object, or objects derived from it.

In our mergesort, we have Merger objects and Sorter objects. We declare them in the common header file pobj_MergeSort.h


#include "gptr_dlist.h"       // Distributed linked list
const int ENDVALUE = -1;

global class Sorter { // Sort a list and place it into out private: int start_index; int stop_index; DList_appending *global out; void sort();

public: Sorter (DList_removing *global out_receiver, int start, int stop); };

global class Merger { // Merge sorted in1 and in2 into sorted out private: DList_removing* in1; DList_removing* in2; DList_appending* out; void merge();

public: Merger (DList_removing *global); DList_removing *global get_in1() { return in1; } DList_removing *global get_in2() { return in2; } };

We are going to use the distributed list built in Chapter to send sorted lists between our processor objects. Thus, each Sorter has a global pointer to a DList_removing on the Merger object that is its parent in the tree. Similarly, each Merger has a global pointer to its parent.

paolo@cs.caltech.edu