请输入您要查询的百科知识:

 

词条 Event (synchronization primitive)
释义

  1. References

  2. External links

In computer science, an event (also called event semaphore) is a type of synchronization mechanism that is used to indicate to waiting processes when a particular condition has become true.

An event is an abstract data type with a boolean state and the following operations:

  • wait - when executed, causes the suspension of the executing process until the state of the event is set to true. If the state is already set to true has no effect.{{Clarify|Can "true" pre-exist before there is a wait? Or does a wait occure every time the state is not set to true?|date=February 2017}}
  • set - sets the event's state to true, release all waiting processes.
  • clear - sets the event's state to false.

Different implementations of events may provide different subsets of these possible operations; for example, the implementation provided by Microsoft Windows provides the operations wait (WaitForObject and related functions), set (SetEvent), and clear (ResetEvent). An option that may be specified during creation of the event object changes the behaviour of SetEvent so that only a single thread is released and the state is automatically returned to false after that thread is released.

Events short of reset function, that is, those which can be completed only once, are known as futures.[1] Monitors are, on the other hand, more general since they combine completion signaling with mutex and do not let the producer and consumer to execute simultaneously in the monitor making it an event+critical section.

References

1. ^500 lines or less, "A Web Crawler With asyncio Coroutines" by A. Jesse Jiryu Davis and Guido van Rossum says "implementation uses an asyncio.Event in place of the Future shown here. The difference is an Event can be reset, whereas a Future cannot transition from resolved back to pending."

External links

  • Event Objects, Microsoft Developer Network
  • Thread Synchronization Mechanisms in Python
{{compsci-stub}}

2 : Concurrency control|Events (computing)

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/18 14:08:28