Skip to content
Snippets Groups Projects
CNDFS.h 1.5 KiB
Newer Older
  • Learn to ignore specific revisions
  • //
    // Created by ghofrane on 5/4/22.
    //
    #ifndef PMC_SOG_CNDFS_H
    #define PMC_SOG_CNDFS_H
    
    chihebabid's avatar
    chihebabid committed
    #include "../ModelCheckBaseMT.h"
    
    #include <spot/tl/apcollect.hh>
    
    chihebabid's avatar
    chihebabid committed
    #include <cstdint>
    #include <thread>
    
    Ghofrane Amaimi's avatar
    Ghofrane Amaimi committed
    #include <atomic>
    #include <condition_variable>
    
    #include <spot/twa/twagraph.hh>
    
    Ghofrane Amaimi's avatar
    Ghofrane Amaimi committed
    
    
    class CNDFS {
    
    Ghofrane Amaimi's avatar
    Ghofrane Amaimi committed
    
    private:
    
    chihebabid's avatar
    chihebabid committed
        static constexpr uint8_t MAX_THREADS=64;
        ModelCheckBaseMT * mMcl;
        spot::twa_graph_ptr mAa;
    
    chihebabid's avatar
    chihebabid committed
        uint16_t mNbTh;
    
    chihebabid's avatar
    chihebabid committed
        atomic<uint8_t> mIdThread;
        static void threadHandler(void *context);
        std::thread* mlThread[MAX_THREADS];
    
    Ghofrane Amaimi's avatar
    Ghofrane Amaimi committed
        mutex *mMutex;
        condition_variable cv;
    
    chihebabid's avatar
    chihebabid committed
        void spawnThreads();
    
        typedef struct _state{
            LDDState *left;
            const spot::twa_graph_state* right;
    
            vector<pair<_state* , int>> new_successors ;
            bool isAcceptance = false;
    
            bool isConstructed = false;
    
    Ghofrane Amaimi's avatar
    Ghofrane Amaimi committed
            inline static thread_local atomic_bool cyan = {false};
            bool blue = false;
            bool red = false;
    
    Ghofrane Amaimi's avatar
    Ghofrane Amaimi committed
    
    
        list<spot::formula> transitionNames;
    
    chihebabid's avatar
    chihebabid committed
        CNDFS(ModelCheckBaseMT *mcl,const spot::twa_graph_ptr &af,const uint16_t& nbTh);
    
        virtual ~CNDFS();
    
        void computeSuccessors(_state *state);
    
        void dfsBlue(_state *state);
        _state* getInitialState();
    
    Ghofrane Amaimi's avatar
    Ghofrane Amaimi committed
        void dfsRed(_state* state);
        void WaitForTestCompleted(_state* state);
        atomic_bool awaitCondition(_state* state);
    
        _state* buildState(LDDState* left, spot::state* right, vector<pair<_state *, int>> succ, bool acc, bool constructed);
    
    chihebabid's avatar
    chihebabid committed
        static spot::bdd_dict_ptr* m_dict_ptr;
    
    };
    
    
    #endif //PMC_SOG_CNDFS_H