class Receiver
{
    public Receiver (Signaler s)
    {
        s.sig.connect (on_signal_received);
    }

    private void on_signal_received (Signaler s)
    {
        stdout.printf ("%d\n", s.id);
        stdout.flush ();
    }
}

class Signaler : Object
{
    private static int count = 0;
    public int id = ++count;

    public signal void sig ();
}

void main ()
{
    var signaler = new Signaler ();
    var receiver = new Receiver (signaler);
    signaler.sig (); /* Should print 1 */

    for (int i = 0; i < 1000; i++)
    {
        signaler = new Signaler ();
        signaler.sig (); /* Should never print anything! */
    }
}
