Changeset: aadc1230c385 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=aadc1230c385
Modified Files:
sql/backends/monet5/iot/50_iot.sql
sql/backends/monet5/iot/iot.mal
sql/backends/monet5/iot/petrinet.c
sql/backends/monet5/iot/petrinet.h
Branch: iot
Log Message:
Add PNstop
diffs (87 lines):
diff --git a/sql/backends/monet5/iot/50_iot.sql
b/sql/backends/monet5/iot/50_iot.sql
--- a/sql/backends/monet5/iot/50_iot.sql
+++ b/sql/backends/monet5/iot/50_iot.sql
@@ -39,6 +39,9 @@ create procedure iot.pause()
create procedure iot.wait(cycles integer)
external name iot.wait;
+create procedure iot.stop()
+ external name iot.stop;
+
create procedure iot.deregister("schema" string, name string)
external name iot.deregister;
diff --git a/sql/backends/monet5/iot/iot.mal b/sql/backends/monet5/iot/iot.mal
--- a/sql/backends/monet5/iot/iot.mal
+++ b/sql/backends/monet5/iot/iot.mal
@@ -45,6 +45,10 @@ pattern wait(t:int):void
address PNwait
comment "wait for quiet moment";
+pattern stop():void
+address PNstop
+comment "Wait for all actions ceased";
+
pattern receptor(sch:str,nme:str,dir:str)
address IOTreceptor
comment "External basket location";
diff --git a/sql/backends/monet5/iot/petrinet.c
b/sql/backends/monet5/iot/petrinet.c
--- a/sql/backends/monet5/iot/petrinet.c
+++ b/sql/backends/monet5/iot/petrinet.c
@@ -49,7 +49,7 @@
#define MAXPN 200 /* it is the minimum, if we need more space
GDKrealloc */
-static str statusname[6] = { "init", "running", "waiting", "paused"};
+static str statusname[6] = { "init", "running", "waiting",
"paused","stopping"};
/* keep track of running tasks */
static int PNcycle;
@@ -227,7 +227,18 @@ PNwait(Client cntxt, MalBlkPtr mb, MalSt
(void) mb;
_DEBUG_PETRINET_ mnstr_printf(cntxt->fdout, "#scheduler wait cycle %d
steps %d\n",old,steps);
- while( PNcycle < old + steps)
+ while(pnstatus == PNRUNNING && PNcycle < old + steps)
+ MT_sleep_ms(20);
+ return MAL_SUCCEED;
+}
+
+/* safely stop the engine by stopping all CQ firt */
+str
+PNstop(void){
+ int i=0;
+ _DEBUG_PETRINET_ mnstr_printf(PNout, "#scheduler being stopped\n");
+ pnstatus = PNSTOP;
+ while( i++ < 10000 && pnstatus != PNINIT)
MT_sleep_ms(20);
return MAL_SUCCEED;
}
@@ -413,7 +424,7 @@ PNscheduler(void *dummy)
pnstatus = PNRUNNING; // global state
- while( pnettop > 0){
+ while( pnettop > 0 && pnstatus != PNSTOP && cntxt->mode !=
FINISHCLIENT){
PNcycle++;
/* Determine which continuous query are eligble to run
Collect latest statistics, note that we don't need a lock
here,
diff --git a/sql/backends/monet5/iot/petrinet.h
b/sql/backends/monet5/iot/petrinet.h
--- a/sql/backends/monet5/iot/petrinet.h
+++ b/sql/backends/monet5/iot/petrinet.h
@@ -32,6 +32,7 @@
#define PNRUNNING 1 /* query is running */
#define PNWAIT 2 /* wait for data */
#define PNPAUSED 3 /* not active now */
+#define PNSTOP 4 /* stop all activity */
#define PAUSEDEFAULT 1000
@@ -42,6 +43,7 @@ iot_export str PNresume(Client cntxt, Ma
iot_export str PNpause(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
iot_export str PNwait(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
iot_export str PNcycles(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
+iot_export str PNstop(void);
iot_export str PNdump(void *ret);
iot_export str PNperiod(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list