[DGD] max_ticks question

Petter Nyström jimorie at gmail.com
Fri Aug 5 18:59:13 CEST 2011


On Fri, Aug 5, 2011 at 5:49 PM, Kent Mein <mein at cs.umn.edu> wrote:
> I think this is obviously the kind of application that the
> MAX_TICKS are needed for so I don't want to make them unlimited.
> Is just increasing MAX_TICKS the best strategy for something like this?

On Fri, Aug 5, 2011 at 6:10 PM, Noah Gibbs <noah_gibbs at yahoo.com> wrote:
> [...] You'd have to divide it up somehow, of course.

Like Noah said, in order for it to scale to an unlimited number of
rooms, you need to divide your algorithm to run over multiple
execution rounds. (Or were execution rounds called tasks now? I keep
forgetting.)

This is done using the call_out() kfun, as you may already know...

One example of how that could be done is to remove the loop and what
comes after it from your main function, and instead call a function
there, that does something like this:

void print_nodes_step (string *files, varargs int i)
{
    do
    {
        if (i >= sizeof(files))
        {
            break;
        }

        print_node(files[i++],str);
    }
    while (status()[ST_TICKS] >
SOME_NUMBER_SUFFICIENTLY_BETWEEN_0_AND_MAX_TICKS)

    if (i >= sizeof(files))
    {
        write_file(filename,"}\n");
        write_file(filename,"# End: str\n");
    }
    else
    {
        call_out("print_nodes_step", 0, files, i);
    }
}

Regards,
Petter



More information about the DGD mailing list