more Vala examples
This commit is contained in:
parent
1326067d6a
commit
f6286c4032
|
@ -0,0 +1,30 @@
|
|||
class Node : Object {
|
||||
public Node prev;
|
||||
public weak Node next;
|
||||
|
||||
public Node (Node? prev = null) {
|
||||
this.prev = prev; // ref
|
||||
if (prev != null) {
|
||||
prev.next = this; // ref
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void main () {
|
||||
var n1 = new Node (); // ref
|
||||
var n2 = new Node (n1); // ref
|
||||
|
||||
// print the reference count of both objects
|
||||
stdout.printf ("%u, %u\n", n1.ref_count, n2.ref_count);
|
||||
|
||||
} // unref, unref
|
||||
*/
|
||||
|
||||
void main () {
|
||||
while (true) {
|
||||
var n1 = new Node ();
|
||||
var n2 = new Node (n1);
|
||||
Thread.usleep (100);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue