Annotation of parser3/src/include/pa_code_cache.h, revision 1.1

1.1     ! moko        1: /** @file
        !             2:        Parser: compiled code cache.
        !             3: 
        !             4:        Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com)
        !             5:        Authors: Konstantin Morshnev <moko@design.ru>
        !             6: */
        !             7: 
        !             8: #ifndef PA_CODE_CACHE_H
        !             9: #define PA_CODE_CACHE_H
        !            10: 
        !            11: #define IDENT_PA_CODE_CACHE_H "$Id$"
        !            12: 
        !            13: #include "pa_request.h"
        !            14: 
        !            15: /// httpd mode: file compilations while the config runs are recorded and replayed in the subsequent requests
        !            16: #define CODE_CACHE
        !            17: 
        !            18: #ifdef CODE_CACHE
        !            19: 
        !            20: /// compilation recording, includes cached methods and all class modifications
        !            21: class Code_cache: public PA_Object {
        !            22: public:
        !            23:        enum Kind { CLASS, USE, BASE, OPTION, METHOD, MAIN };
        !            24: 
        !            25:        struct Action {
        !            26:                Kind kind;
        !            27:                const String* name; // class, base class, used file, option or method name
        !            28:                Method* method;
        !            29:                Operation::Origin origin; // of @USE
        !            30:        };
        !            31: 
        !            32:        Array<Action> actions;
        !            33:        const String& file_spec;
        !            34:        uint file_no; // index in request.file_list
        !            35: 
        !            36:        Code_cache(const String& afile_spec);
        !            37:        void add(Kind kind, const String* name=0, Method* method=0);
        !            38:        void add_use(const String* name, Operation::Origin origin);
        !            39:        bool unchanged();
        !            40: 
        !            41:        /// replays the compilation, see compile.C
        !            42:        ArrayClass& replay(Request& r, VStateless_class& aclass);
        !            43: 
        !            44: private:
        !            45:        uint64_t fsize;
        !            46:        time_t fmtime;
        !            47: };
        !            48: 
        !            49: class Code_cache_manager {
        !            50: public:
        !            51:        /// the httpd config runs between these
        !            52:        static void start();
        !            53:        static void finish(Request& r);
        !            54: 
        !            55:        /// $MAIN:HTTPD.code-cache, taken while the config runs
        !            56:        static void set_enabled(bool aenabled);
        !            57: 
        !            58:        /// so that the file numbers in the cached code are valid in the request
        !            59:        static void add_files(Array<String::Body>& file_list);
        !            60: 
        !            61:        /// if code is cached and unchanged
        !            62:        static Code_cache* get(const String& file_spec);
        !            63: 
        !            64:        /// while the config runs: where to record the file compilation
        !            65:        static Code_cache* create(const String& file_spec);
        !            66:        /// after the file is compiled
        !            67:        static void put(Code_cache& code);
        !            68: };
        !            69: 
        !            70: #endif
        !            71: 
        !            72: #endif

E-mail: