Ejemplo n.º 1
0
			public: const node_ref<T>& get_child(size_t index) const{
				assert(check_invariant());
				assert(index < BRANCHING_FACTOR);
				assert(index < _children.size());

				return _children[index];
			}
Ejemplo n.º 2
0
			//	You can only call this for leaf nodes.
			public: const leaf_node<T>* get_child_as_leaf_node(size_t index) const{
				assert(check_invariant());
				assert(index < _children.size());
				assert(_children[0].get_type() == node_type::leaf_node);

				return _children[index]._leaf_node;
			}
Ejemplo n.º 3
0
			public: leaf_node(const std::array<T, BRANCHING_FACTOR>& values) :
				_rc(0),
				_values(values)
			{
				_debug_count++;
				assert(check_invariant());
			}
Ejemplo n.º 4
0
 void doClosed (IP::Endpoint const& remote_endpoint, bool graceful)
 {
     // Find our link to them
     Links::iterator const iter (std::find_if (
         m_links.begin(), m_links.end(),
             is_remote_endpoint (remote_endpoint)));
     // Must be connected!
     check_invariant (iter != m_links.end());
     // Must be closed!
     check_invariant (iter->closed());
     // Remove our link to them
     m_links.erase (iter);
     // Notify
     m_network.post (std::bind (&Logic::on_closed,
         &logic(), remote_endpoint));
 }
Ejemplo n.º 5
0
			//	Counts the children actually used = skips trailing any null children.
			public: size_t count_children() const{
				assert(check_invariant());

				size_t index = 0;
				while(index < _children.size() && _children[index].get_type() != node_type::null_node){
					index++;
				}
				return index;
			}
Ejemplo n.º 6
0
 void clause_set::insert(clause & c) {
     unsigned id  = c.id();
     m_id2pos.reserve(id+1, UINT_MAX);
     if (m_id2pos[id] != UINT_MAX)
         return; // already in the set
     unsigned pos = m_set.size();
     m_id2pos[id] = pos;
     m_set.push_back(&c);
     CASSERT("clause_set", check_invariant());
 }
Ejemplo n.º 7
0
		~invariant_checker_impl()
		{
			try
			{
				check_invariant(self);
			}
			catch (...)
			{
				TORRENT_ASSERT(false);
			}
		}
Ejemplo n.º 8
0
		invariant_checker_impl(T const& self_)
			: self(self_)
		{
			try
			{
				check_invariant(self);
			}
			catch (...)
			{
				TORRENT_ASSERT(false);
			}
		}
Ejemplo n.º 9
0
			//	children: 0-32 children, all of the same type. kNullNodes can only appear at end of vector.
			public: inode(const children_t& children2) :
				_rc(0),
				_children(children2)
			{
				assert(children2.size() >= 0);
				assert(children2.size() <= BRANCHING_FACTOR);
		#if STEADY_ASSERT_ON
				for(auto i: children2){
					i.check_invariant();
				}
		#endif

				_debug_count++;
				assert(check_invariant());
			}
Ejemplo n.º 10
0
 void clause_set::erase(clause & c) { 
     unsigned id = c.id();
     if (id >= m_id2pos.size())
         return;
     unsigned pos = m_id2pos[id];
     if (pos == UINT_MAX)
         return;
     m_id2pos[id] = UINT_MAX;
     unsigned last_pos = m_set.size() - 1;
     if (pos != last_pos) {
         clause * last_c = m_set[last_pos];
         m_set[pos] = last_c; 
         m_id2pos[last_c->id()] = pos;
     }
     m_set.pop_back();
     CASSERT("clause_set", check_invariant());
 }
Ejemplo n.º 11
0
    void doDisconnectPeer (IP::Endpoint const& remote_endpoint, bool graceful)
    {
        // Find our link to them
        Links::iterator const iter1 (std::find_if (
            m_links.begin(), m_links.end(),
                is_remote_endpoint (remote_endpoint)));
        if (iter1 == m_links.end())
            return;
        Node& remote_node (iter1->remote_node());
        IP::Endpoint const local_endpoint (iter1->local_endpoint());
        // Find their link to us
        Links::iterator const iter2 (std::find_if (
            remote_node.links().begin(), remote_node.links().end(),
                is_remote_endpoint (local_endpoint)));
        if (iter2 != remote_node.links().end())
        {
            // Notify the remote that we closed
            check_invariant (! iter2->closed());
            iter2->close();
            m_network.post (std::bind (&Node::doClosed,
                &remote_node, local_endpoint, graceful));
        }
        if (! iter1->closed ())
        {
            // Remove our link to them
            m_links.erase (iter1);
            // Notify
            m_network.post (std::bind (&Logic::on_closed,
                &logic(), remote_endpoint));
        }

        /*
        if (! graceful || ! iter2->pending ())
        {
            remote_node.links().erase (iter2);
            remote_node.logic().on_closed (local_endpoint);
        }
        */
    }
Ejemplo n.º 12
0
 void run ()
 {
     int shouldBeZero (1);
     check_invariant (shouldBeZero == 0);
 }
Ejemplo n.º 13
0
		~invariant_checker_impl()
		{
			check_invariant(self);
		}
Ejemplo n.º 14
0
		explicit invariant_checker_impl(T const& self_)
			: self(self_)
		{
			check_invariant(self);
		}
Ejemplo n.º 15
0
			public: leaf_node() :
				_rc(0)
			{
				_debug_count++;
				assert(check_invariant());
			}
Ejemplo n.º 16
0
			//	Returns entire array, even if not all items are used.
			public: children_t get_child_array() const{
				assert(check_invariant());

				return _children;
			}
Ejemplo n.º 17
0
			public: ~inode(){
				assert(check_invariant());
				assert(_rc == 0);

				_debug_count--;
			}