Author |
Message |
alexbarbed
Joined: Apr 09, 2011 Posts: 14 Location: UK
|
Posted: Sat Apr 16, 2011 10:03 am Post subject:
Public class already declared in namespace... help! |
|
|
Hi
As I understand it, in order to share data between shreds, I need to first declare them as static variables in a public class. This all works fine, the shreds can then use the variables. However... when I want to change the code of this public class while I'm developing it, I can't because the class is already declared in the namespace. I have to stop the VM every time, which from miniAudicle is a considerable hassle as it means quitting and then going into task manager and killing the process. Same in Audicle. I'm trying out the command line version and it seems OK but I can't quite figure it out - what's the best way to do this?
Anyone faced and overcome this issue? Am I doing something dumb?
Cheers
Alex |
|
Back to top
|
|
|
witt0191
Joined: Feb 13, 2008 Posts: 23 Location: UK
|
Posted: Mon Apr 18, 2011 5:18 am Post subject:
|
|
|
hi,
When you say that you have tried it with the command line are you just doing chuck <file.ck> or chuck --loop.
As chuck --loop is akin to the miniAudicle VM behaviour while the other once starts and stops the VM as the file executes. |
|
Back to top
|
|
|
alexbarbed
Joined: Apr 09, 2011 Posts: 14 Location: UK
|
Posted: Tue May 10, 2011 4:18 am Post subject:
|
|
|
I wasn't using --loop... now I am. Thanks! |
|
Back to top
|
|
|
jordan
Joined: May 16, 2011 Posts: 5 Location: Brooklyn, New York
|
Posted: Mon May 16, 2011 10:07 am Post subject:
|
|
|
If you're working at the command line, it's easier to write it into the code to handle the launching of new scripts using Machine.add("path_to_your_script.ck").
Let's say you have some shared data being defined in a script - "parent.ck", and that is accessed from a script that will spork a bunch of shreds - "children.ck". I would define a third script, let's call it "run.ck". So it'd look like this:
run.ck:
--------------------------------------------------------------------------------
Machine.add("parent.ck");
Machine.add("children.ck");
--------------------------------------------------------------------------------
parent.ck:
--------------------------------------------------------------------------------
public class MrGenerous {
static int someSharedThing;
}
--------------------------------------------------------------------------------
children.ck:
--------------------------------------------------------------------------------
fun void access_shared() {
// do something with MrGenerous.someSharedThing here
}
spork ~ access_shared();
spork ~ access_shared();
spork ~ access_shared();
// don't forget to keep this shred alive to preserve its decedents.
while(true) {
100::ms => now;
}
--------------------------------------------------------------------------------
then at the command line you can just say "chuck run.ck" (or "chuck run") |
|
Back to top
|
|
|
alexbarbed
Joined: Apr 09, 2011 Posts: 14 Location: UK
|
Posted: Mon May 16, 2011 3:10 pm Post subject:
|
|
|
Neat! Thanks! |
|
Back to top
|
|
|
|