PyQt5线程队列------LinkNode

import sys
import os

from PyQt5.QtCore import QObject
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QGuiApplication

"""模块路径加到当前模块扫描的路径里"""
sys.path.append(os.path.dirname(__file__))
# import numpy as np
# import cv2
"""
@项目 :ThreadLoop
@文件 :LinkNode.py    
@作者 :xsh
@时间 :2021/11/21 15:20
@功能 :
@说明 :

"""
from myThread import myThread, DrawInfo


class LinkNode(QObject):
    """当前节点的编号"""
    CurrentThreadNumber: int
    """当前节点线程"""
    CurrentThread: myThread
    """上一个节点"""
    LastNode: 'LinkNode'
    """下一个节点"""
    NextNode: 'LinkNode'

    def __init__(self, number=int(0), parent=None):
        super(LinkNode, self).__init__(parent)
        self.CurrentThreadNumber = number
        self.CurrentThread = myThread(self.CurrentThreadNumber, None)
        self.LastNode = None
        self.NextNode = None
    def __del__(self):
        if self.CurrentThread:
            self.CurrentThread.Stop(True)
            self.CurrentThread.deleteLater()
    """停止当前节点的线程"""
    def Stop(self):
        self.CurrentThread.Stop(True)
        while self.CurrentThread.isRunning():
            pass
        pass
    """暂停当前节点的线程"""
    def Pause(self):
        if self.CurrentThread.getPause():
            return
        else:
            self.CurrentThread.Pause(True)
        pass
    """启动当前节点的线程"""
    def Start(self, *args):
        self.CurrentThread.Start(*args)
        pass
    """线程是否空闲"""
    def isFree(self) -> bool:
        return self.CurrentThread.getPause()

    """线程是否在运行"""
    def isRunning(self) -> bool:
        return self.CurrentThread.getStop() is False

 

上一篇:Java 基础(Thread类的有关方法,线程的调度)


下一篇:同步队列