1.23
2.0
acw/focus-triggers
main
test-branch
| Line | |
|---|
| 1 | #ifndef _CIVL_COLLATE_
|
|---|
| 2 | #define _CIVL_COLLATE_
|
|---|
| 3 |
|
|---|
| 4 | #include<collate.cvh>
|
|---|
| 5 | #include<civlc.cvh>
|
|---|
| 6 | /******************* Definition of datatypes: *******************/
|
|---|
| 7 |
|
|---|
| 8 | struct _gcollator {
|
|---|
| 9 | // The number of participants of a _gcollator object:
|
|---|
| 10 | int nprocs;
|
|---|
| 11 | // $proc array:
|
|---|
| 12 | $proc procs[];
|
|---|
| 13 | // The length of the queue of collation states:
|
|---|
| 14 | int queue_length;
|
|---|
| 15 | // The queue of collation states. Note that elements in this queue
|
|---|
| 16 | // are references to collate state objects:
|
|---|
| 17 | $gcollate_state queue[];
|
|---|
| 18 | };
|
|---|
| 19 |
|
|---|
| 20 | struct _collator {
|
|---|
| 21 | // The place of the process in a _gcollator who holds this handle:
|
|---|
| 22 | int place;
|
|---|
| 23 | // A handle to the _gcollator object:
|
|---|
| 24 | $gcollator gcollator;
|
|---|
| 25 | };
|
|---|
| 26 |
|
|---|
| 27 | struct _gcollate_state {
|
|---|
| 28 | // An array of markers for whether a process has already arrived
|
|---|
| 29 | // this entry:
|
|---|
| 30 | _Bool arrived[];
|
|---|
| 31 | // An array of markers for whether a process has already departed
|
|---|
| 32 | // from this entry:
|
|---|
| 33 | _Bool departed[];
|
|---|
| 34 | // collate $state:
|
|---|
| 35 | $state state;
|
|---|
| 36 | };
|
|---|
| 37 |
|
|---|
| 38 | struct _collate_state {
|
|---|
| 39 | // The place of the process in a _gcollator who holds this handle:
|
|---|
| 40 | int place;
|
|---|
| 41 | // A reference to a _gcollate_state:
|
|---|
| 42 | $gcollate_state gstate;
|
|---|
| 43 | };
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | /******************* Function definitions ***************************/
|
|---|
| 47 | $gcollator gcollator_create($scope scope, int nprocs) {
|
|---|
| 48 | $gcollator gcollator = ($gcollator)$malloc(scope, sizeof(struct _gcollator));
|
|---|
| 49 |
|
|---|
| 50 | gcollator_obj->nprocs = nprocs;
|
|---|
| 51 | gcollator_obj->procs = (($proc[nprocs])$lambda(int i)$proc_null);
|
|---|
| 52 | gcollator_obj->queue_length = 0;
|
|---|
| 53 | $seq_init(&(gcollator_obj->queue), 0, NULL);
|
|---|
| 54 | return gcollator;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | #endif
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.