zoukankan      html  css  js  c++  java
  • python模拟进程状态

     1 from transitions import Machine
     2 # 定义一个自己的类
     3 class Matter(object):
     4     pass
     5 model = Matter()
     6 states = ['New', 'Ready', 'Waiting', 'Running','Terminated']
     7 # The trigger argument defines the name of the new triggering method
     8 transitions = [
     9     {'trigger': 'Admitted', 'source': 'New', 'dest': 'Ready'},
    10     {'trigger': 'Dispatch', 'source': 'Ready', 'dest': 'Running'},
    11     {'trigger': 'Input/Output or event wait', 'source': 'Running', 'dest': 'Waiting'},
    12     {'trigger': 'Input/Output or event completion', 'source': 'Waiting', 'dest': 'Ready'},
    13     {'trigger':'Exit','source':'Running','dest':'Terminated'},
    14     {'trigger':'Interrupt','source':'Running','dest':'Ready'}]
    15 # 初始化
    16 machine = Machine(model=model, states=states,transitions=transitions, initial='New')
    17 # Test
    18 print(model.state)
    19 model.Admitted()
    20 print(model.state)   
    第二种
  • 相关阅读:
    实现可折叠的列表
    ajax知识点补充
    Ajax 完整教程
    从页面左边飞入页面动画效果
    文字闪烁
    点击按钮之后等待60秒
    [SCOI2016]萌萌哒
    [HNOI2011]卡农
    [NOI2015]寿司晚宴
    【bzoj 3489】A simple rmq problem
  • 原文地址:https://www.cnblogs.com/20201212ycy/p/14111175.html
Copyright © 2011-2022 走看看