swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ordering events in a swarm ....


From: xueyue
Subject: Re: ordering events in a swarm ....
Date: Tue, 08 Jun 1999 09:14:19 +0000

Ken Cline wrote:
> 
> Xueyue,
> 
> Could you clarify a few things...
> 
>  > -buildActions {
>  >   ...
>  > [schedulerSwarm buildActions];
>  >   ...
>  > }
>  > -activateIn: context {
>  >   ...
>  > [schedulerSwarm buildActions];
>  >   ...
>  > } 
> Is this right?  Are you calling `buildActions' twice?
> 
No, this shoud be [schedulerSwarm activateIn: self];
The code is very long, so, I just abstract it.

>  > [schedulerSwarm newScheduleAt: (timeval_t) t target: (id)tg
>  >                                             message: (SEL) msg];
> 
> What does the `newScheduleAt:target:message:' method look
> like?  This seems to be the method you think is not working
> correctly and it would be easier to understand what's
> happening if you posted that part of the source code, as
> well.
-newScheduleAt:target:message method calls directly an object
"schedule" in schedulerSwarm of class Schedule:
-newScheduleAt: (timeval_t) t target: (id) tg message: (SEL)msg {
        [schedule at: t createActionTo: tg message: msg];
        return self;
}


 
>  > in the observerSwarm, I have a test method:

>  > -test {
>  >  printf("I am testing schedulerSwarm ....\n");
>  > return self;
>  > }
> 
> I gather from the rest of of your message that the `test'
> method is actually in the `schedulerSwarm' and not in the
> `observerSwarm', is that correct?
 
No, test is in observerSwarm.
 
>  > and a method -step which is scheduled to be called at
>  > at every step:
>  >
>  > -step {
>  >  timeval_t tm [timeSwarm getTime];
>  >  int x = 5;
>  >  tm=tm+x;
>  >  [schedulerSwarm newScheduleAt: tm target: self message: M(test)];
>  > return self;
>  > }
> 
> This `step' method shouldn't compile since you are missing a
> `=' on the first line.  I presume that otherwise this
> matches your source code exactly, right?
As I said this is abstract code, there is "=" in it in real code.
>  > here timeSwarm is another swarm, which serves as a clock,
>  > and -getTime will get current time.
> 
> To simplify the problem, you could replace the `[timeSwarm
> getTime]' call with the macro `getCurrentTime()'.  I do not
> think that will fix your problem, since you've probably
> already tested that `getTime' returns the correct value.  I
> only suggest using `getCurrentTime()' so others can
> duplicate the problem; alternatively you could post the
> code to `getTime'.
There is no problem with timeSwarm, which will serve as a clock
converting the time from 'getCurrentTime()' into 
year, hour, ..., second. But that should be fine.
>  > x is an integer produced by uniformIntRand. (there is
>  > <random.h>, x is corretly produced ---can be tested
>  > by printf("x is %d ...", x)), ...
> 
> Be sure to check the `tm' value since it is the one used to
> schedule the action(s).
> 
>  > however, the programme will no longer work!
> 
> What do you mean? Does it compile? If it compiles then what
> errors do you get?  Have you run it in a debugger? What does
> the backtrace look like?  (The more information you can
> provide the easier it'll be to find the problem.)
> 
> Also, it would be good to know which version of swarm you
> are using.
> 
> Ken.
> 

Alright, dear Ken,
I think the problem in short here is:

(1) A swarm is build, in which an object, schedule, of 
class Schedule is built. and -setAutoDrop:1 is called by schedule, so
that every time, an action is scheduled, it will 
be excuted just once. 
(2) If actions are passed to 'schedule' one by one according
to their order of excuting, there is no problem met.
(3) If actions are passed in random order, i.e., some actions 
which will be excuted later might be passed to 'schedule' earlier than
some others. In this cass, the programme will still be compiled and run,
but no actions are excuted at all.

So, the question here really is: can 'schedule' randomly  
schedule events and excute them in their supposed order? 
This question is really for the Schedule class developper.








> _________________________________________________________
> Ken Cline                             address@hidden
> SAIC                                 VOICE (410) 571-0413
> Annapolis, MD                          FAX (301) 261-8427
> 
>                   ==================================
>    Swarm-Support is for discussion of the technical details of the day
>    to day usage of Swarm.  For list administration needs (esp.
>    [un]subscribing), please send a message to <address@hidden>
>    with "help" in the body of the message.

-- 
Dr Xueyue Huang
Center for Transport Studies
Imperial College 
London SW7 2BU

(+44) 171 594 6037

Attachment: vcard.vcf
Description: Card for Xueyue Huang


reply via email to

[Prev in Thread] Current Thread [Next in Thread]