Changes in / [3c6480b7:36ec816]
- Files:
-
- 3 edited
-
libcfa/src/bits/multi_list.cfa (modified) (3 diffs)
-
libcfa/src/bits/sequence.hfa (modified) (2 diffs)
-
tests/.expect/manipulatorsOutput2.arm64.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/multi_list.cfa
r3c6480b7 r36ec816 2 2 #include <stdlib.hfa> 3 3 #include "sequence.hfa" 4 #include "queue.hfa"5 4 #include "stack.hfa" 6 5 … … 9 8 struct TaskDL { 10 9 inline Seqable; 11 Task & node;10 Task & task_; 12 11 }; 13 12 void ?{}( TaskDL & this, Task & task ) with( this ) { 14 13 ((Seqable &)this){}; 15 & node= &task; // pointer to containing node14 &task_ = &task; // pointer to containing node 16 15 } 17 16 Task & task( TaskDL & this ) with( this ) { // getter routine for containing node 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; 17 return task_; 31 18 } 32 19 … … 34 21 TaskDL clusterRef; // list of tasks on cluster 35 22 TaskDL readyRef; // list of tasks on ready queue 36 TaskSL mutexRef; // list of tasks on mutex queue 37 int id; 23 // other stuff 38 24 }; 39 void ?{}( Task & this , int id) with( this ) {25 void ?{}( Task & this ) with( this ) { 40 26 ((TaskDL &)clusterRef){ this }; 41 27 ((TaskDL &)readyRef){ this }; 42 ((TaskSL &)mutexRef){ this };43 this.id = id;44 28 } 45 29 46 30 int main() { 47 31 Sequence(TaskDL) clustList, readyList; // task lists 48 Queue(TaskSL) mutexList;49 32 enum { Lnth = 10 }; 50 33 51 for ( id;Lnth ) {52 Task & task = *new( id );// create task node34 for ( Lnth ) { 35 Task & task = *new(); // create task node 53 36 addHead( clustList, task.clusterRef ); // insert on lists in opposite directions 54 37 addTail( readyList, task.readyRef ); 55 addHead( mutexList, task.mutexRef );56 38 } 57 39 58 SeqIter(TaskDL) sqiter;40 SeqIter(TaskDL) iter; 59 41 TaskDL & dl; 60 TaskSL & sl;61 42 62 43 sout | nlOff; 63 for ( over( sqiter, clustList ); sqiter >> dl; ) { // print lists 64 Task & tmp = task( dl ); sout | tmp.id; 65 // sout | task( dl ).id; 44 for ( over( iter, clustList ); iter >> dl; ) { // print lists 45 sout | &task( dl ); 66 46 } 67 47 sout | nl; 68 for ( over( sqiter, readyList ); sqiter >> dl; ) { 69 Task & tmp = task( dl ); sout | tmp.id; 70 // sout | task( dl ).id; 48 for ( SeqIter(TaskDL) iter = { readyList }; iter >> dl; ) { 49 sout | &task( dl ); 71 50 } 72 51 sout | nl; 73 for ( QueueIter(TaskSL) qiter = { mutexList }; qiter >> sl; ) { // print lists 74 Task & tmp = task( sl ); sout | tmp.id; 75 // sout | task( sl ).id; 52 for ( Lnth ) { // remove nodes from clustList 53 dropHead( clustList ); 76 54 } 77 sout | nl;78 for ( Lnth ) { // remove nodes from clustList. mutexList79 dropHead( clustList );80 drop( mutexList );81 }82 // Simultaneous deletion only safe if all nodes are traversed in same direction.83 55 for ( Lnth ) { // remove nodes from readyList and safe to delete nodes 84 56 delete( &task( dropHead( readyList ) ) ); 85 57 } 86 58 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 } 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 // } 101 64 } -
libcfa/src/bits/sequence.hfa
r3c6480b7 r36ec816 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. Without214 // passing the sequence, traversing would require its length. Thus the iterator needs a pointer to the sequence215 // to pass to succ/pred. Both stack and queue just encounter 0p since the lists are not circular.216 213 Sequence(T) * seq; 217 214 }; … … 254 251 struct SeqIterRev { 255 252 inline ColIter; 256 // See above for explanation.257 253 Sequence(T) * seq; 258 254 }; -
tests/.expect/manipulatorsOutput2.arm64.txt
r3c6480b7 r36ec816 1 1 2 2 0b0 0b11011 0b11011 0b11011 0b11011 3 0b11100101 0b1111111111100101 0b11111111111111111111111111100101 0b111111111111111111111111111 11111111111111111111111111111111001013 0b11100101 0b1111111111100101 0b11111111111111111111111111100101 0b11111111111111111111111111100101 4 4 0 033 033 033 033 5 0345 0177745 037777777745 0 17777777777777777777455 0345 0177745 037777777745 037777777745 6 6 0 0x1b 0x1b 0x1b 0x1b 7 0xe5 0xffe5 0xffffffe5 0xffffff ffffffffe58 0x0p+0. 0x1.b8p+4 0x1.b8p+4 0x 1.b8p+49 -0x1.b8p+4 -0x1.b8p+4 -0x 1.b8p+47 0xe5 0xffe5 0xffffffe5 0xffffffe5 8 0x0p+0. 0x1.b8p+4 0x1.b8p+4 0xd.cp+1 9 -0x1.b8p+4 -0x1.b8p+4 -0xd.cp+1 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.