Annotation of parser3/src/classes/memory.C, revision 1.19

1.2       paf         1: /** @file
                      2:        Parser: @b memory parser class.
                      3: 
1.18      moko        4:        Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com)
1.2       paf         5:        Author: Alexandr Petrosian <paf@design.ru>(http://paf.design.ru)
                      6: */
                      7: 
                      8: #include "pa_common.h"
                      9: #include "pa_vmemory.h"
                     10: #include "pa_request.h"
1.19    ! moko       11: #include "pa_vmethod_frame.h"
1.2       paf        12: 
1.19    ! moko       13: volatile const char * IDENT_MEMORY_C="$Id: memory.C,v 1.18 2020/12/15 17:10:29 moko Exp $" IDENT_PA_VMEMORY_H;
1.9       moko       14: 
1.2       paf        15: class MMemory: public Methoded {
                     16: public:
                     17:        MMemory();
                     18: 
                     19: public: // Methoded
                     20:        bool used_directly() { return false; }
                     21: };
                     22: 
                     23: // global variables
                     24: 
1.11      moko       25: DECLARE_CLASS_VAR(memory, new MMemory);
1.2       paf        26: 
1.4       paf        27: static void _compact(Request& r, MethodParams&) {
1.2       paf        28:        r.wipe_unused_execution_stack();
1.19    ! moko       29:        pa_gc_collect(true);
        !            30: }
        !            31: 
        !            32: static void _auto_compact(Request& r, MethodParams& params) {
        !            33:        int divisor = params.as_int(0, "frequency must be int", r);
        !            34:        if(divisor<0 || divisor>5)
        !            35:                throw Exception(PARSER_RUNTIME, 0, "frequency '%d' is out of range 0..5", divisor);
        !            36:        pa_gc_set_free_space_divisor(divisor);
1.13      moko       37: }
1.2       paf        38: 
                     39: // constructor
                     40: 
                     41: MMemory::MMemory(): Methoded("memory") {
                     42:        // ^compact[]
                     43:        add_native_method("compact", Method::CT_STATIC, _compact, 0, 0);
1.19    ! moko       44:        // ^auto-compact(N)
        !            45:        add_native_method("auto-compact", Method::CT_STATIC, _auto_compact, 1, 1);
1.2       paf        46: }

E-mail: