zoukankan      html  css  js  c++  java
  • queue — A synchronized queue class

    https://docs.python.org/3.6/library/queue.html

    https://github.com/python/cpython/blob/3.6/Lib/queue.py

    The queue module implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multiple threads. The Queue class in this module implements all the required locking semantics. It depends on the availability of thread support in Python; see the threading module.

    The module implements three types of queue, which differ only in the order in which the entries are retrieved. In a FIFO queue, the first tasks added are the first retrieved. In a LIFO queue, the most recently added entry is the first retrieved (operating like a stack). With a priority queue, the entries are kept sorted (using the heapq module) and the lowest valued entry is retrieved first.

    Internally, the module uses locks to temporarily block competing threads; however, it is not designed to handle reentrancy within a thread.

    The queue module defines the following classes and exceptions:

    class queue.Queue(maxsize=0)

    Constructor for a FIFO queue. maxsize is an integer that sets the upperbound limit on the number of items that can be placed in the queue. Insertion will block once this size has been reached, until queue items are consumed. If maxsize is less than or equal to zero, the queue size is infinite.

    class queue.LifoQueue(maxsize=0)

    Constructor for a LIFO queue. maxsize is an integer that sets the upperbound limit on the number of items that can be placed in the queue. Insertion will block once this size has been reached, until queue items are consumed. If maxsize is less than or equal to zero, the queue size is infinite.

    class queue.PriorityQueue(maxsize=0)

    Constructor for a priority queue. maxsize is an integer that sets the upperbound limit on the number of items that can be placed in the queue. Insertion will block once this size has been reached, until queue items are consumed. If maxsize is less than or equal to zero, the queue size is infinite.

    The lowest valued entries are retrieved first (the lowest valued entry is the one returned by sorted(list(entries))[0]). A typical pattern for entries is a tuple in the form: (priority_number, data).

    exception queue.Empty

    Exception raised when non-blocking get() (or get_nowait()) is called on a Queue object which is empty.

    exception queue.Full

    Exception raised when non-blocking put() (or put_nowait()) is called on a Queue object which is full.

  • 相关阅读:
    手机端@media screen布局自适应
    JavaScript-判断语句(if...else)
    JavaScript-什么是变量
    网页上缺少标识符、字符串或数字怎么解决?
    jquery.qrcode.min.js生成二维码 通过前端实现二维码生成
    一步一回头撞在了南墙上
    C#中另类自定义公式计算 字符串转换为计算公式,并得出计算结果
    C#判断操作系统是32位还是64位(转)
    实现HTML调用打开本地软件文件
    记某图片下载器破解笔记之增加试用次数
  • 原文地址:https://www.cnblogs.com/rsapaper/p/7979568.html
Copyright © 2011-2022 走看看