00001 #ifndef LOCK_QBOX_H 00002 #define LOCK_QBOX_H 00003 00004 #include "QBox.h" 00005 #include <vector> 00006 00007 #include <ext/hash_map> 00008 00009 BOREALIS_NAMESPACE_BEGIN; 00010 00011 class LockQBox : public QBox 00012 { 00013 public: 00014 ~LockQBox(); 00015 00016 private: 00017 ptr<LockSet> _lock_set; 00018 ptr<Expression> _key_expr; 00019 typedef __gnu_cxx::hash_map<int, list<string> > PendingMap; 00020 PendingMap _pending_tuples; 00021 EvalContext _ctxt; 00022 size_t _tuple_size; 00023 00024 protected: 00025 void setupImpl() throw (AuroraException); 00026 void initImpl() throw (AuroraException); 00027 void runImpl(QBoxInvocation&) throw (AuroraException); 00028 00029 AURORA_DECLARE_QBOX(LockQBox, "lock"); 00030 }; 00031 00032 BOREALIS_NAMESPACE_END; 00033 00034 template<typename T, typename U> 00035 inline string to_string(const __gnu_cxx::hash_map<T,U>& m) { 00036 string out = "{"; 00037 00038 for (typename __gnu_cxx::hash_map<T, U>::const_iterator i = m.begin(); i != m.end(); ++i) { 00039 if (i != m.begin()) out.append("; "); 00040 out.append(to_string(i->first)).append("->").append(to_string(i->second)); 00041 } 00042 00043 out.append("}"); 00044 return out; 00045 } 00046 00047 #endif