[chuck-users] is shred running? (Atte)

Atte atte at youmail.dk
Sun Mar 15 04:43:58 EDT 2015


On 03/09/2015 01:57 PM, Atte wrote:

> I hope nothing gets changed with .exit(), since that seems the be the
> one that works the best :-)

I've been having huge problems with the suggested way of figuring out if
a shred is running. I've cut down the scenario as much as possible,
three files, supply your own beat:

--- lib_sporker.ck ---
public class Sporker{
    public static int add(string filename){
        Machine.add(filename) => int id;
        return id;
    }

    public static void remove(int id){
        Machine.remove(id);
        //Shred.fromId(id).exit();
    }

    public static int is_running(int id){
        return(Shred.fromId(id) != null);
        //return Shred.fromId(id).running();
        //return !Shred.fromId(id).done();
    }
}

Sporker dummy;
100::week => now;
---

--- sporker.ck ---
Sporker.add("beat") => int id;
<<<id>>>;
<<<Sporker.is_running(23)>>>;
<<<Sporker.is_running(id)>>>;
1000::ms => now;
Sporker.remove(id);
<<<Sporker.is_running(id)>>>;
---

--- beat.ck ---
SndBuf s => dac;
s.read("plastic_jam.wav");
1 => s.loop;
1::week => now;
---

The problem seems to be that as soon as the Shred.fromId(some_id) has
been called, Machine.remove(some_id) might kill the thread, but the
SndBuf keeps playing...

Any ideas?

Note that this is a reduced part of something larger. So the structure
although it might seem odd in this small example has to be this way (I'm
pretty sure), for instance the Sporker has to be a singleton since it is
used for sporking and bookkeeping from various other places in the system.

-- 
Atte

http://atte.dk   http://a773.dk


More information about the chuck-users mailing list