|
13 | 13 | class YRoomManager(): |
14 | 14 | """ |
15 | 15 | A singleton that manages all `YRoom` instances in the server extension. This |
16 | | - automatically deletes empty `YRoom`s with no connected clients or active |
17 | | - kernel every 10 seconds. |
| 16 | + automatically deletes `YRoom` instances if they have had no connected |
| 17 | + clients or active kernel for >10 seconds. |
18 | 18 |
|
19 | 19 | Because rooms may be deleted due to inactivity, consumers should only store |
20 | 20 | a reference to the room ID and call `get_room(room_id)` each time a |
21 | | - reference to the room is needed. This method is cheap as long as the room |
22 | | - still exists. |
| 21 | + reference to the room is needed. See `get_room()` for more details. |
23 | 22 | """ |
24 | 23 |
|
25 | 24 | _rooms_by_id: dict[str, YRoom] |
@@ -79,12 +78,17 @@ def fileid_manager(self) -> BaseFileIdManager: |
79 | 78 |
|
80 | 79 | def get_room(self, room_id: str) -> YRoom | None: |
81 | 80 | """ |
82 | | - Retrieves a YRoom given a room ID. If the YRoom does not exist, this |
83 | | - method will initialize a new YRoom. |
| 81 | + Returns the `YRoom` instance for a given room ID. If the instance does |
| 82 | + not exist, this method will initialize one and return it. Otherwise, |
| 83 | + this method returns the instance from its cache, ensuring that this |
| 84 | + method is fast in almost all cases. |
84 | 85 |
|
85 | | - This method ensures that the returned room will be alive for >10 |
| 86 | + Consumers should always call this method each time a reference to the |
| 87 | + `YRoom` is needed, since rooms may be deleted due to inactivity. |
| 88 | +
|
| 89 | + This method also ensures that the returned room will be alive for >10 |
86 | 90 | seconds. This prevents the room from being deleted shortly after the |
87 | | - consumer receives it via this method, even if it is inactive. |
| 91 | + consumer receives it via this method, even if it was inactive. |
88 | 92 | """ |
89 | 93 | # First, ensure this room stays open for >10 seconds by removing it from |
90 | 94 | # the inactive set of rooms if it is present. |
|
0 commit comments