Loading tnl2/event_connection.h +7 −15 Original line number Diff line number Diff line Loading @@ -18,20 +18,6 @@ enum rpc_guarantee_type { rpc_unguaranteed = 2 ///< Event delivery is not guaranteed - however, the event will remain ordered relative to other unguaranteed events. }; uint32 hash_buffer(const void *buffer, uint32 len) { uint8 *buf = (uint8 *) buffer; uint32 result = 0; while(len--) result = ((result << 8) | (result >> 24)) ^ uint32(*buf++); return result; } template <typename signature> uint32 hash_method(signature the_method) { return hash_buffer((void *) &the_method, sizeof(the_method)); } class event_connection : public net_connection { public: Loading Loading @@ -89,6 +75,12 @@ public: the_record.method_hash = hash_method(the_method); rpc_methods.push_back(the_record); } template <class T> void rpc(void (T::*method)()) { uint32 method_hash = hash_method(method); functor_decl<void (T::*)()> *f = new functor_decl<void (T::*)()>(method); call_rpc(method_hash, f); } template <class T, class A> void rpc(void (T::*method)(A), A arg1) { uint32 method_hash = hash_method(method); Loading Loading @@ -315,7 +307,7 @@ public: previous_sequence = seq; } int32 start = bstream.get_bit_position(); //int32 start = bstream.get_bit_position(); uint32 rpc_index = bstream.read_integer(_rpc_id_bit_size); if(rpc_index >= _rpc_count) throw tnl_exception_invalid_packet; Loading tnl2/exceptions.h +2 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ enum tnl_exceptions { tnl_exception_invalid_packet = 0xBEEF, tnl_exception_number_out_of_range, tnl_exception_ghost_add_failed, tnl_exception_illegal_rpc, }; tnl2/ghost_connection.h +983 −943 File changed.Preview size limit exceeded, changes collapsed. Show changes tnl2/net_connection.h +1 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ public: virtual bool read_connect_accept(bit_stream &accept_stream, bit_stream &response_stream) { return true; } virtual void on_connection_rejected(bit_stream &reject_stream) Loading tnl2/net_interface.h +69 −21 Original line number Diff line number Diff line class net_connection; class net_object; class net_interface : public ref_object { public: net_interface(SOCKADDR *bind_address) { _socket = torque_socket_create(bind_address); } friend class net_object; virtual ~net_interface() typedef hash_table_array<torque_connection, ref_ptr<net_connection> >::pointer connection_pointer; struct connection_type_record { torque_socket_destroy(_socket); } uint32 identifier; type_record *type; }; public: void set_private_key(asymmetric_key_ptr the_key) { byte_buffer_ptr private_key = the_key->get_private_key(); Loading Loading @@ -78,17 +79,6 @@ public: } } } hash_table_array<torque_connection, ref_ptr<net_connection> > _connection_table; typedef hash_table_array<torque_connection, ref_ptr<net_connection> >::pointer connection_pointer; struct connection_type_record { uint32 identifier; type_record *type; }; array<connection_type_record> _connection_class_table; template<class connection_type> void add_connection_type(uint32 identifier) { type_record *the_type_record = get_global_type_record<connection_type>(); Loading Loading @@ -123,7 +113,44 @@ public: return 0; } time _process_start_time; void collapse_dirty_list() { for(net_object *obj = _dirty_list_head._next_dirty_list; obj != &_dirty_list_tail; ) { net_object *next = obj->_next_dirty_list; uint32 or_mask = obj->_dirty_mask_bits; obj->_next_dirty_list = NULL; obj->_prev_dirty_list = NULL; obj->_dirty_mask_bits = 0; if(or_mask) { for(ghost_info *walk = obj->_first_object_ref; walk; walk = walk->next_object_ref) { if(!walk->update_mask) { walk->update_mask = or_mask; walk->connection->ghost_push_non_zero(walk); } else walk->update_mask |= or_mask; } } obj = next; } _dirty_list_head._next_dirty_list = &_dirty_list_tail; _dirty_list_tail._prev_dirty_list = &_dirty_list_head; } void add_to_dirty_list(net_object *obj) { assert(obj->_next_dirty_list == 0); assert(obj->_prev_dirty_list == 0); obj->_next_dirty_list = _dirty_list_head._next_dirty_list; obj->_next_dirty_list->_prev_dirty_list = obj; _dirty_list_head._next_dirty_list = obj; obj->_prev_dirty_list = &_dirty_list_head; } time get_process_start_time() { Loading Loading @@ -293,6 +320,27 @@ public: torque_socket_connect(_socket, connect_address, connect_stream.get_next_byte_position(), connect_buffer); } virtual ~net_interface() { torque_socket_destroy(_socket); } net_interface(SOCKADDR *bind_address) { _socket = torque_socket_create(bind_address); _dirty_list_head._next_dirty_list = &_dirty_list_tail; _dirty_list_tail._prev_dirty_list = &_dirty_list_head; _dirty_list_head._prev_dirty_list = 0; _dirty_list_tail._next_dirty_list = 0; } private: torque_socket _socket; time _process_start_time; net_object _dirty_list_head; net_object _dirty_list_tail; array<connection_type_record> _connection_class_table; hash_table_array<torque_connection, ref_ptr<net_connection> > _connection_table; }; Loading
tnl2/event_connection.h +7 −15 Original line number Diff line number Diff line Loading @@ -18,20 +18,6 @@ enum rpc_guarantee_type { rpc_unguaranteed = 2 ///< Event delivery is not guaranteed - however, the event will remain ordered relative to other unguaranteed events. }; uint32 hash_buffer(const void *buffer, uint32 len) { uint8 *buf = (uint8 *) buffer; uint32 result = 0; while(len--) result = ((result << 8) | (result >> 24)) ^ uint32(*buf++); return result; } template <typename signature> uint32 hash_method(signature the_method) { return hash_buffer((void *) &the_method, sizeof(the_method)); } class event_connection : public net_connection { public: Loading Loading @@ -89,6 +75,12 @@ public: the_record.method_hash = hash_method(the_method); rpc_methods.push_back(the_record); } template <class T> void rpc(void (T::*method)()) { uint32 method_hash = hash_method(method); functor_decl<void (T::*)()> *f = new functor_decl<void (T::*)()>(method); call_rpc(method_hash, f); } template <class T, class A> void rpc(void (T::*method)(A), A arg1) { uint32 method_hash = hash_method(method); Loading Loading @@ -315,7 +307,7 @@ public: previous_sequence = seq; } int32 start = bstream.get_bit_position(); //int32 start = bstream.get_bit_position(); uint32 rpc_index = bstream.read_integer(_rpc_id_bit_size); if(rpc_index >= _rpc_count) throw tnl_exception_invalid_packet; Loading
tnl2/exceptions.h +2 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ enum tnl_exceptions { tnl_exception_invalid_packet = 0xBEEF, tnl_exception_number_out_of_range, tnl_exception_ghost_add_failed, tnl_exception_illegal_rpc, };
tnl2/ghost_connection.h +983 −943 File changed.Preview size limit exceeded, changes collapsed. Show changes
tnl2/net_connection.h +1 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ public: virtual bool read_connect_accept(bit_stream &accept_stream, bit_stream &response_stream) { return true; } virtual void on_connection_rejected(bit_stream &reject_stream) Loading
tnl2/net_interface.h +69 −21 Original line number Diff line number Diff line class net_connection; class net_object; class net_interface : public ref_object { public: net_interface(SOCKADDR *bind_address) { _socket = torque_socket_create(bind_address); } friend class net_object; virtual ~net_interface() typedef hash_table_array<torque_connection, ref_ptr<net_connection> >::pointer connection_pointer; struct connection_type_record { torque_socket_destroy(_socket); } uint32 identifier; type_record *type; }; public: void set_private_key(asymmetric_key_ptr the_key) { byte_buffer_ptr private_key = the_key->get_private_key(); Loading Loading @@ -78,17 +79,6 @@ public: } } } hash_table_array<torque_connection, ref_ptr<net_connection> > _connection_table; typedef hash_table_array<torque_connection, ref_ptr<net_connection> >::pointer connection_pointer; struct connection_type_record { uint32 identifier; type_record *type; }; array<connection_type_record> _connection_class_table; template<class connection_type> void add_connection_type(uint32 identifier) { type_record *the_type_record = get_global_type_record<connection_type>(); Loading Loading @@ -123,7 +113,44 @@ public: return 0; } time _process_start_time; void collapse_dirty_list() { for(net_object *obj = _dirty_list_head._next_dirty_list; obj != &_dirty_list_tail; ) { net_object *next = obj->_next_dirty_list; uint32 or_mask = obj->_dirty_mask_bits; obj->_next_dirty_list = NULL; obj->_prev_dirty_list = NULL; obj->_dirty_mask_bits = 0; if(or_mask) { for(ghost_info *walk = obj->_first_object_ref; walk; walk = walk->next_object_ref) { if(!walk->update_mask) { walk->update_mask = or_mask; walk->connection->ghost_push_non_zero(walk); } else walk->update_mask |= or_mask; } } obj = next; } _dirty_list_head._next_dirty_list = &_dirty_list_tail; _dirty_list_tail._prev_dirty_list = &_dirty_list_head; } void add_to_dirty_list(net_object *obj) { assert(obj->_next_dirty_list == 0); assert(obj->_prev_dirty_list == 0); obj->_next_dirty_list = _dirty_list_head._next_dirty_list; obj->_next_dirty_list->_prev_dirty_list = obj; _dirty_list_head._next_dirty_list = obj; obj->_prev_dirty_list = &_dirty_list_head; } time get_process_start_time() { Loading Loading @@ -293,6 +320,27 @@ public: torque_socket_connect(_socket, connect_address, connect_stream.get_next_byte_position(), connect_buffer); } virtual ~net_interface() { torque_socket_destroy(_socket); } net_interface(SOCKADDR *bind_address) { _socket = torque_socket_create(bind_address); _dirty_list_head._next_dirty_list = &_dirty_list_tail; _dirty_list_tail._prev_dirty_list = &_dirty_list_head; _dirty_list_head._prev_dirty_list = 0; _dirty_list_tail._next_dirty_list = 0; } private: torque_socket _socket; time _process_start_time; net_object _dirty_list_head; net_object _dirty_list_tail; array<connection_type_record> _connection_class_table; hash_table_array<torque_connection, ref_ptr<net_connection> > _connection_table; };