peng3d/util/__init__.py
def genNewID(self):
        """
        Generates a new ID.
        
        If ``reuse_ids`` was false, the new ID will be read from an internal counter
        which is also automatically increased. This means that the newly generated ID is already reserved.
        
        If ``reuse_ids`` was true, this method starts counting up from ``start_id`` until it finds an
        ID that is not currently known. Note that the ID is not reserved, this means that
        calling this method simultaneously from multiple threads may cause the same ID to be returned twice.
        
        Additionally, if the ID is greater or equal to ``max_id``\ , an :py:exc:`AssertionError` is raised.
        """
        if self.reuse_ids:
            i = self.start_id
            while True:
                if i not in self._data["reg"]:
                    assert i<=self.max_id
                    return i # no need to change any variables
                i+=1
        else:
            with self.id_lock:
                # new id creation in lock, to avoid issues with multiple threads
                i = self._data["next_id"]
                assert i<=self.max_id
                self._data["next_id"]+=1
            return i
def genNewID(self):
        """
        Generates a new ID.
        
        If ``reuse_ids`` was false, the new ID will be read from an internal counter
        which is also automatically increased. This means that the newly generated ID is already reserved.
        
        If ``reuse_ids`` was true, this method starts counting up from ``start_id`` until it finds an
        ID that is not currently known. Note that the ID is not reserved, this means that
        calling this method simultaneously from multiple threads may cause the same ID to be returned twice.
        
        Additionally, if the ID is greater or equal to ``max_id``\ , an :py:exc:`AssertionError` is raised.
        """
        if self.reuse_ids:
            i = self.start_id
            while True:
                if i not in self._data["reg"]:
                    assert i<=self.max_id
                    return i # no need to change any variables
                i+=1
        else:
            with self.id_lock:
                # new id creation in lock, to avoid issues with multiple threads
                i = self._data["next_id"]
                assert i<=self.max_id
                self._data["next_id"]+=1
            return i
Generates a new ID.
        
        If ``reuse_ids`` was false, the new ID will be read from an internal counter
        which is also automatically increased. This means that the newly generated ID is already reserved.
        
        If ``reuse_ids`` was true, this method starts counting up from ``start_id`` until it finds an
        ID that is not currently known. Note that the ID is not reserved, this means that
        calling this method simultaneously from multiple threads may cause the same ID to be returned twice.
        
        Additionally, if the ID is greater or equal to ``max_id``\ , an :py:exc:`AssertionError` is raised.