Update of /cvsroot/monetdb/MonetDB5/src/modules/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13013/modules/mal

Modified Files:
        recycle.mx 
Log Message:
Moveing code around to please Windows


Index: recycle.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/mal/recycle.mx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- recycle.mx  3 Mar 2008 08:11:13 -0000       1.2
+++ recycle.mx  6 Mar 2008 20:26:43 -0000       1.3
@@ -49,17 +49,160 @@
 address RECYCLEsetCache
 comment "Set recycler cache policy";
 
+command shutdown():void
+address RECYCLEshutdown
+comment "Clear the recycle cache";
 @h
 #ifndef _RECYCLE_
 #define _RECYCLE_
 
 #include "mal.h"
+#include "mal_instruction.h"
 #include "mal_recycle.h"
 
+#ifdef WIN32
+#ifndef LIBRECYCLE
+#define recycle_export extern __declspec(dllimport)
+#else
+#define recycle_export extern __declspec(dllexport)
+#endif
+#else
+#define recycle_export extern
+#endif
+
+recycle_export str RECYCLEdump(int *ret);
+recycle_export str RECYCLEstart(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
+recycle_export str RECYCLEstop(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
+recycle_export str RECYCLEsetRetain(int *ret, sht *p);
+recycle_export str RECYCLEsetReuse(int *ret, sht *p);
+recycle_export str RECYCLEsetCache(int *ret, sht *p);
+recycle_export str RECYCLEshutdown(int *ret);
+
 #endif
 @-
 @c
 #include "mal_config.h"
+#include "mal_function.h"
 #include "recycle.h"
 
[EMAIL PROTECTED]
+The recycler is started when the first function is called for its support.
+Upon exit of the last function, the content of the recycle cache is destroyed.
[EMAIL PROTECTED]
+str
+RECYCLEstart(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+
+       (void) pci;
+       (void) stk;
+
+       if( recycleVersion == 0){       
+               MT_lock_init(&recycleLock,"recycle");
+               recycleVersion =1 ;
+       }
+       if( mb->version )
+               /* upgrade to a new version by dropping old info */
+               RECYCLEversion(mb);
+       else{
+               mal_set_lock(recycleLock,"recycle");
+               mb->version= recycleVersion;
+               recycleUsers++;
+               mal_unset_lock(recycleLock,"recycle");
+       }
+#ifdef _DEBUG_RECYCLE_
+       stream_printf(GDKout,"RECYCLEstart version %d\n",recycleVersion);
+#endif
+       return MAL_SUCCEED;
+}
+
+
+str
+RECYCLEstop(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       (void) mb;
+       (void) stk;
+       (void) pci;
+       if( recycleBlk == 0)
+               return MAL_SUCCEED;
+       mal_set_lock(recycleLock,"recycle");
+       recycleBlk->version = 0;
+       recycleUsers--;
+       mal_unset_lock(recycleLock,"recycle");
+       return MAL_SUCCEED;
+}
+
+
+str
+RECYCLEdump(int *ret)
+{
+       int i;
+
+       (void) ret;
+       stream_printf(GDKout,"Recycler  catalog \n");
+       printFunction(GDKout,recycleBlk, LIST_MAL_ALL);
+
+       /* and dump the statistics */
+       for(i=0; i< recycleBlk->stop; i++){
+               stream_printf(GDKout,"#%d count=%d ticks=%d\n", i,
+                       recycleBlk->profiler[i].counter,
+                       recycleBlk->profiler[i].ticks);
+       }
+       return MAL_SUCCEED;
+}
+
+str
+RECYCLEsetRetain(int *ret, sht *p)
+{
+       (void) ret;
+       retainPolicy = *p;
+       (void)retainPolicy;
+       return MAL_SUCCEED;
+}
+
+str
+RECYCLEsetReuse(int *ret, sht *p)
+{
+       (void) ret;
+       reusePolicy = *p;
+       (void)reusePolicy;
+       return MAL_SUCCEED;
+}
+
+str
+RECYCLEsetCache(int *ret, sht *p)
+{
+       (void) ret;
+       rcachePolicy = *p;
+       (void)rcachePolicy;
+       return MAL_SUCCEED;
+}
[EMAIL PROTECTED]
+At the end of the session we have to cleanup the recycle cache.
[EMAIL PROTECTED]
+str
+RECYCLEshutdown(int *ret){
+       InstrPtr q;
+       int i,j;
+       MalBlkPtr mb;
+       
+       (void)ret;
+       if( recycleBlk == NULL)
+               return MAL_SUCCEED;
+
+       mal_set_lock(recycleLock,"recycle");
+       mb= recycleBlk;
+       recycleBlk= NULL;
+       mal_unset_lock(recycleLock,"recycle");
+
+       for(i=0; i< mb->stop; i++){
+               q= getInstrPtr(mb,i);
+               for(j=0; j< q->argc; j++)
+               if( isVarConstant(mb,getArg(q,j)) ){
+                       if( isaBatType(getArgType(mb, q,j)) )
+                               
BBPreleaseref(getVarConstant(mb,getArg(q,j)).val.bval);
+               }
+       }
+       freeMalBlk(mb);
+       return MAL_SUCCEED;
+}
 @}


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to