Changeset 3c6480b7
- Timestamp:
- Dec 4, 2020, 11:49:34 AM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- fe3d9ab
- Parents:
- 36ec816 (diff), 54f89d5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/multi_list.cfa
r36ec816 r3c6480b7 2 2 #include <stdlib.hfa> 3 3 #include "sequence.hfa" 4 #include "queue.hfa" 4 5 #include "stack.hfa" 5 6 … … 8 9 struct TaskDL { 9 10 inline Seqable; 10 Task & task_;11 Task & node; 11 12 }; 12 13 void ?{}( TaskDL & this, Task & task ) with( this ) { 13 14 ((Seqable &)this){}; 14 & task_= &task; // pointer to containing node15 &node = &task; // pointer to containing node 15 16 } 16 17 Task & task( TaskDL & this ) with( this ) { // getter routine for containing node 17 return task_; 18 return node; 19 } 20 21 struct TaskSL { 22 inline Colable; 23 Task & node; 24 }; 25 void ?{}( TaskSL & this, Task & task ) with( this ) { 26 ((Colable &)this){}; 27 &node = &task; // pointer to containing node 28 } 29 Task & task( TaskSL & this ) with( this ) { // getter routine for containing node 30 return node; 18 31 } 19 32 … … 21 34 TaskDL clusterRef; // list of tasks on cluster 22 35 TaskDL readyRef; // list of tasks on ready queue 23 // other stuff 36 TaskSL mutexRef; // list of tasks on mutex queue 37 int id; 24 38 }; 25 void ?{}( Task & this ) with( this ) {39 void ?{}( Task & this, int id ) with( this ) { 26 40 ((TaskDL &)clusterRef){ this }; 27 41 ((TaskDL &)readyRef){ this }; 42 ((TaskSL &)mutexRef){ this }; 43 this.id = id; 28 44 } 29 45 30 46 int main() { 31 47 Sequence(TaskDL) clustList, readyList; // task lists 48 Queue(TaskSL) mutexList; 32 49 enum { Lnth = 10 }; 33 50 34 for ( Lnth ) {35 Task & task = *new( );// create task node51 for ( id; Lnth ) { 52 Task & task = *new( id ); // create task node 36 53 addHead( clustList, task.clusterRef ); // insert on lists in opposite directions 37 54 addTail( readyList, task.readyRef ); 55 addHead( mutexList, task.mutexRef ); 38 56 } 39 57 40 SeqIter(TaskDL) iter;58 SeqIter(TaskDL) sqiter; 41 59 TaskDL & dl; 60 TaskSL & sl; 42 61 43 62 sout | nlOff; 44 for ( over( iter, clustList ); iter >> dl; ) { // print lists 45 sout | &task( dl ); 63 for ( over( sqiter, clustList ); sqiter >> dl; ) { // print lists 64 Task & tmp = task( dl ); sout | tmp.id; 65 // sout | task( dl ).id; 46 66 } 47 67 sout | nl; 48 for ( SeqIter(TaskDL) iter = { readyList }; iter >> dl; ) { 49 sout | &task( dl ); 68 for ( over( sqiter, readyList ); sqiter >> dl; ) { 69 Task & tmp = task( dl ); sout | tmp.id; 70 // sout | task( dl ).id; 50 71 } 51 72 sout | nl; 52 for ( Lnth ) { // remove nodes from clustList 73 for ( QueueIter(TaskSL) qiter = { mutexList }; qiter >> sl; ) { // print lists 74 Task & tmp = task( sl ); sout | tmp.id; 75 // sout | task( sl ).id; 76 } 77 sout | nl; 78 for ( Lnth ) { // remove nodes from clustList. mutexList 53 79 dropHead( clustList ); 80 drop( mutexList ); 54 81 } 82 // Simultaneous deletion only safe if all nodes are traversed in same direction. 55 83 for ( Lnth ) { // remove nodes from readyList and safe to delete nodes 56 84 delete( &task( dropHead( readyList ) ) ); 57 85 } 58 86 59 // Stack(TaskDL) fredStack; 60 // for ( Lnth ) { 61 // Task & task = *new(); // create task node 62 // push( fredStack, task.clusterRef ); // insert on lists in opposite directions 63 // } 87 // Re-purpose Seqable as Colable 88 Stack(TaskDL) mutexStack; 89 for ( id; Lnth ) { 90 Task & task = *new( id ); // create task node 91 push( mutexStack, task.clusterRef ); // insert on lists in opposite directions 92 } 93 for ( StackIter(TaskDL) stiter = { mutexStack }; stiter >> dl; ) { 94 Task & tmp = task( dl ); sout | tmp.id; 95 // sout | task( dl ).id; 96 } 97 sout | nl; 98 for ( Lnth ) { // remove nodes from readyList and safe to delete nodes 99 delete( &task( pop( mutexStack ) ) ); 100 } 64 101 } -
libcfa/src/bits/sequence.hfa
r36ec816 r3c6480b7 211 211 struct SeqIter { 212 212 inline ColIter; 213 // The Sequence must be passed to pred and succ to check for the end of the Sequence and return 0p. Without 214 // passing the sequence, traversing would require its length. Thus the iterator needs a pointer to the sequence 215 // to pass to succ/pred. Both stack and queue just encounter 0p since the lists are not circular. 213 216 Sequence(T) * seq; 214 217 }; … … 251 254 struct SeqIterRev { 252 255 inline ColIter; 256 // See above for explanation. 253 257 Sequence(T) * seq; 254 258 }; -
tests/.expect/manipulatorsOutput2.arm64.txt
r36ec816 r3c6480b7 1 1 2 2 0b0 0b11011 0b11011 0b11011 0b11011 3 0b11100101 0b1111111111100101 0b11111111111111111111111111100101 0b111111111111111111111111111 001013 0b11100101 0b1111111111100101 0b11111111111111111111111111100101 0b1111111111111111111111111111111111111111111111111111111111100101 4 4 0 033 033 033 033 5 0345 0177745 037777777745 0 377777777455 0345 0177745 037777777745 01777777777777777777745 6 6 0 0x1b 0x1b 0x1b 0x1b 7 0xe5 0xffe5 0xffffffe5 0xffffff e58 0x0p+0. 0x1.b8p+4 0x1.b8p+4 0x d.cp+19 -0x1.b8p+4 -0x1.b8p+4 -0x d.cp+17 0xe5 0xffe5 0xffffffe5 0xffffffffffffffe5 8 0x0p+0. 0x1.b8p+4 0x1.b8p+4 0x1.b8p+4 9 -0x1.b8p+4 -0x1.b8p+4 -0x1.b8p+4 10 10 0.000000e+00 2.750000e+01 -2.750000e+01 11 11 0B11011 0X1B 2.75E-09 0X1.B8P+4
Note: See TracChangeset
for help on using the changeset viewer.