[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Q] dynamic scheduling, cleaning up remaining scheduled events
From: |
Marcus G. Daniels |
Subject: |
Re: [Q] dynamic scheduling, cleaning up remaining scheduled events |
Date: |
13 Aug 1999 07:46:18 -0700 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4 |
>>>>> "NEN" == Norberto Eiji Nawa <address@hidden> writes:
NEN> I wonder if there is any function to "clean-up" a dynamic
NEN> schedule, i.e., to remove all the unexecuted events/actions that
NEN> may be remaining on it.
Not a nice terse way, but you can do something like below.
(Specifically the "if (t == 2)" conditional.)
#import <simtools.h>
#import <activity.h>
#import <objectbase/Swarm.h>
@interface Controller: Swarm
{
id schedule;
}
+ createBegin: aZone;
- activateIn: swarmContext;
- step;
@end
@implementation Controller
+ createBegin: aZone
{
Controller *obj = [super createBegin: aZone];
obj->schedule = [Schedule create: aZone];
return obj;
}
- createEnd
{
[super createEnd];
[schedule at: 0 createActionTo: self message: M(step)];
[schedule at: 1 createActionTo: self message: M(step)];
[schedule at: 2 createActionTo: self message: M(step)];
[schedule at: 3 createActionTo: self message: M(step)];
[schedule at: 4 createActionTo: self message: M(step)];
return self;
}
- step
{
timeval_t t = getCurrentTime ();
printf ("time: %ld\n", t);
if (t == 2)
{
id index = [schedule createIndex: scratchZone
fromMember: getCurrentAction ()];
while ([index next: (id *) &t])
{
printf ("removing: %ld\n", t);
[index remove];
}
[index drop];
}
return self;
}
- activateIn: swarmContext
{
[super activateIn: swarmContext];
[schedule activateIn: self];
return [self getActivity];
}
- run
{
[self activateIn: nil];
[[self getActivity] run];
return self;
}
@end
int
main (int argc, const char **argv)
{
initSwarmBatch (argc, argv);
[[Controller create: globalZone] run];
return 0;
}
/*
Local Variables:
compile-command: "/opt/gnu/bin/gcc -o s6 -g -Wno-import
-L/opt/SUNWtcl/8.0/sun4/lib -R/opt/SUNWtcl/8.0/sun4/lib -L/opt/SDGblt/2.4g/lib
-R/opt/SDGblt/2.4g/lib -L/opt/SDGlibffi/1.20/lib -R/opt/SDGlibffi/1.20/lib
-L/opt/SDGswarm/1.4.1/lib -L/opt/SDGzlib/1.1.3/lib -L/usr/local/X11/lib
-R/usr/local/X11/lib -L/usr/openwin/lib -R/usr/openwin/lib
-L/opt/SDGhdf5/1.0.1/lib -I/opt/SDGswarm/1.4.1/include s6.m -lanalysis
-lsimtools -lsimtoolsgui -lactivity -ltkobjc -lrandom -lobjectbase -ldefobj
-lcollections -lmisc -ltclobjc -ltk8.0 -ltcl8.0 -lBLT -lsocket -ldl -lnsl
-L/usr/openwin/lib -lhdf5 -lpng -lz -lXpm -lX11 -lffi -lm -lobjc -lpthread
-lposix4"
End:
*/
==================================
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.