#ifndef SLOTS_H #define SLOTS_H /* @author Manuel Jung, */ #include #include #include #include #include #include #include #include "diver.h" #include "myconnection.h" struct query { query(unsigned int id_, unsigned short pr_, unsigned short type_, unsigned short status_); virtual ~query(); enum estatus{WAITING=0, WORKING=1, BUFFERED=2}; unsigned int id; unsigned short pr; unsigned short type; unsigned short status; typedef boost::shared_ptr pointer; }; struct qoctopus : public query { qoctopus(unsigned int id_, unsigned short pr_, unsigned short type_, unsigned short status_); virtual ~qoctopus(); unsigned int ErrorCode; UnicodeString Url; std::string buf; typedef boost::shared_ptr pointer; }; struct tid{}; struct tpr{}; struct ttype{}; struct tseq{}; struct tfree{}; //Some Lists: //arm list //slot list //Queues: //arm queue //slot queue / buffer struct query_rank_key:composite_key< query::pointer, member, member, member >{}; typedef multi_index_container< query::pointer, indexed_by< ordered_non_unique< query_rank_key #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) ,composite_key_result_less #endif >, ordered_unique< tag,member > > > queue_set; class queue : public queue_set { public: typedef boost::shared_ptr pointer; queue(){}; virtual ~queue(){}; boost::mutex m; }; /* class queue : public queue_set { public: queue(){}; virtual ~queue(){}; void AddQuery(query::pointer Query); void RmQuery(query::pointer Query); void Upd(query::pointer Query); boost::mutex m_Queue; typedef boost::shared_ptr pointer; }; typedef nth_index::type queue_by_rank; typedef nth_index::type queue_by_id; */ class slot : public myconnection, public boost::enable_shared_from_this { //Metacrawler public: slot(diver::pointer diver_tmp); virtual ~slot(); // Locking envoirment boost::try_mutex m_idle; boost::condition cond_idle; bool stop; // ------------------ typedef boost::shared_ptr tpointer; virtual void Start(); virtual void Call()=0; virtual void Stop(); tpointer Split(); bool IsIdle(); enum etype{SHARK=0, WHALE=1, DOLPHIN=2}; unsigned int id; query::pointer Query; tpointer Thread; typedef boost::shared_ptr pointer; protected: diver::pointer diver_; diver::TCnv cnv; }; #endif