more Vala examples

This commit is contained in:
Kolan Sh 2012-10-01 17:32:03 +04:00
parent 1326067d6a
commit f6286c4032
1 changed files with 30 additions and 0 deletions

30
vala/hello/memory.vala Normal file
View File

@ -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);
}
}