mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-03 14:04:51 +00:00
Add SeqNo lock
This commit is contained in:
parent
560991498d
commit
aca6fa390e
1 changed files with 8 additions and 4 deletions
|
|
@ -16,12 +16,16 @@
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from threading import Lock
|
||||||
|
|
||||||
|
|
||||||
class SeqNo:
|
class SeqNo:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.content_related_messages_sent = 0
|
self.content_related_messages_sent = 0
|
||||||
|
self.lock = Lock()
|
||||||
|
|
||||||
def __call__(self, is_content_related: bool) -> int:
|
def __call__(self, is_content_related: bool) -> int:
|
||||||
|
with self.lock:
|
||||||
seq_no = (self.content_related_messages_sent * 2) + (1 if is_content_related else 0)
|
seq_no = (self.content_related_messages_sent * 2) + (1 if is_content_related else 0)
|
||||||
|
|
||||||
if is_content_related:
|
if is_content_related:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue