Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Use a set for WheelTimer to better handle duplicates.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed May 6, 2022
1 parent 4ffe7a9 commit aab8569
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions synapse/util/wheel_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Generic, List, TypeVar
from typing import Generic, Hashable, List, Set, TypeVar

T = TypeVar("T")
T = TypeVar("T", bound=Hashable)


class _Entry(Generic[T]):
__slots__ = ["end_key", "queue"]

def __init__(self, end_key: int) -> None:
self.end_key: int = end_key
self.queue: List[T] = []

# We use a set here as otherwise we can end up with a lot of duplicate
# entries.
self.queue: Set[T] = set()


class WheelTimer(Generic[T]):
Expand Down

0 comments on commit aab8569

Please sign in to comment.