Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages

DrmaManager.hpp

Go to the documentation of this file.
00001 #ifndef DrmaManager_HPP
00002 #define DrmaManager_HPP
00003 
00004 #include "Registration.hpp"
00005 #include "Deregistration.hpp"
00006 #include "BspPut.hpp"
00007 #include "BspGetRequest.hpp"
00008 #include "BspGetReply.hpp"
00009 //#include "BspCentral.hpp"
00010 
00011 #include "utils/c++/GuardedVariable.hpp"
00012 #include "utils/c++/Condition.hpp"
00013 
00014 
00015 #include <vector>
00016 #include <pthread.h>
00017 
00018 using namespace std;
00019 
00020 class BspCentral;//For cross-referencing to work
00021 
00022 
00034   class DrmaManager{
00035 
00036    private:
00037 
00038       //Fields------------------------------------------------------------------------------
00039 
00040       std::vector<Registration> registrations;           
00042       std::vector<Registration> pendingRegistrations;    
00045       std::vector<Deregistration> pendingDeregistrations;
00049       std::vector<BspPut> pendingPuts;            
00053       std::vector<BspGetRequest> pendingGetRequests;    
00056       std::vector<BspGetReply> pendingGetReplies;       
00060       GuardedVariable<int> superstep_;                   
00062       pthread_mutex_t pendingRegistrationsLock;          
00063       pthread_mutex_t pendingDeregistrationsLock;        
00064       pthread_mutex_t pendingPutsLock;                   
00065       pthread_mutex_t pendingGetRequestsLock;            
00066       pthread_mutex_t pendingGetRepliesLock;             
00068       GuardedVariable<int> pendingGetRepliesCount;       
00074       Condition noPendingGetReplies;                    
00077       BspCentral * bspCentral_;                         
00079       //Methods----------------------------------------------------------------------------
00080 
00084       void commitPendingGetRequests();
00085 
00090       void commitPendingGetReplies();
00091 
00095       void commitRegistrations();
00096 
00100       void commitDeregistrations();
00101 
00105       void commitPendingPuts();
00106 
00113       void deregister(Deregistration & dereg);
00114 
00115 
00116 
00117   public:
00118 
00125       void addPendingRegistration(void * ptr, int size);
00126 
00132       //TODO: I suppose that removeRegistration should remove the LAST INSERTED
00133       //registration of a given memory address. It is not clear, though, if this
00134       //is the correct behavior
00135       void addPendingDeregistration(void * ptr);
00136 
00140       DrmaManager(BspCentral  * bspCentral);
00141 
00148       void addPendingPut(const BspPut & bspPut);
00149 
00150 
00151 
00157       int findLastRegistration(void * ptr);
00158 
00164       Registration & getRegistration(int pos);
00165 
00169       void processPendingOperations();
00170 
00174       void incSuperstep(){ superstep_.inc(); }
00175 
00179       int superstep(){ return superstep_.value(); }
00180 
00184       void incPendingGetReplies(){pendingGetRepliesCount.inc(); }
00185 
00192       void addPendingGetRequest(const BspGetRequest & request);
00193 
00199       void addPendingGetReply(const BspGetReply & reply);
00200 
00201 
00202 
00203 
00204   };
00205 
00206 #endif//DrmaManager_HPP

Generated on Mon Sep 6 16:12:47 2004 by doxygen 1.3.3