#NativeHashMap

1 messages · Page 1 of 1 (latest)

hexed moth
#

Can i add to nativehashmap on a job? it looks like i`m getting a infinite loop if i try to add to a nativehashmap on a job.

Not parallel and this is the only job acessing the hashmap

open sluice
#

yes

#

just to confirm something

#

if you switch it to NativeParallelHashMap

#

does it have issues?

#

NativeHashMap used to be NativeParallelHashMap

#

they added a new faster implementation for when you only used it in a single thread

hexed moth
#

No, even with NativeParallelHashMap it enters on infinite loop

#
                            {
                                Debug.Log("Added");
                            }
                            else
                            {
                                Debug.Log("Not added");
                            }``` the code can`t even log anything
#
    public struct Address : IEquatable<Address> {
        [FieldOffset(0)]
        private ulong address0;
        [FieldOffset(8)]
        private ulong address1;
        [FieldOffset(16)]
        public ushort port;

        public bool Equals(Address other) {
            return address0 == other.address0 && address1 == other.address1 && port == other.port;
        }

        public override bool Equals(object obj) {
            if (obj is Address)
                return Equals((Address)obj);

            return false;
        }

        public override int GetHashCode() {
            int hash = 17;

            hash = hash * 31 + address0.GetHashCode();
            hash = hash * 31 + address1.GetHashCode();
            hash = hash * 31 + port.GetHashCode();

            return hash;
        }

        public override string ToString() {
            StringBuilder ip = new StringBuilder(64);

            NanoSockets.UDP.GetIP(ref this, ip, 64);

            return String.Format("IP:{0} Port:{1}", ip, this.port);
        }

        public static Address CreateFromIpPort(string ip, ushort port) {
            Address address = default(Address);

            NanoSockets.UDP.SetIP(ref address, ip);
            address.port = port;

            return address;
        }
    }```
#

this is my hashmap key. I will try with another type. It is strange

open sluice
#

this hash map usually infinite loops when something unsafe is being done

#

but you don't appear to have turned off safety on it