mechaware——理解事件确认

本文通过邮件传递的比喻,深入浅出地介绍了事件通知的工作原理。包括如何使用线程等待事件、轮询事件以及如何处理事件积压等情况。文章还详细解释了mpiNotifyEventWait和mpiNotifyEventFlush的功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Event Notification 事件确认机理

The best way to understand how event notification works, is to use a mail delivery analogy. Think of yourself as your program. If you use a thread to wait for events (mpiNotifyEventWait), you are waiting for the mail carrier (Event Manager). If you are polling for events (mpiNotifyEventWait), you check the mail periodically.

使用信封传递的例子来理解事件确认(event notification)。把自己当做一个程序,如果使用一个线程等待事件(比如mpiNotifyEventWait线程),你正在等邮递员(event manager)。如果轮询事件(mpiNotifyEventWait),那么你是在定期的查看邮件。这是两种处理事件的方式。

When the firmware sends an event, it is like a friend (MPI Object) sending you (Thread) a letter (ex: Event -- Motion Done). The letter (Event) travels to the post office (Controller Event Pool) where your mail carrier (Event Manager) retrieves it and then delivers it to your mailbox (Notify Object).

当固件(firmware)发送一个事件时,就好像一个朋友(MPI Object)发送给你(线程)一封信(事件之Motion Done)。这封信(事件)先到邮局(控制器事件池),在这里邮递员(event manager)检索它并把它传送到你的邮箱(notify 对象)。

Here are the three common cases:

下面是常见的几个例子:

 
  1. Thread Waiting for Events 线程中等待事件
    As soon as the mail carrier (Event Manager) shows up, the thread in your program checks the mailbox (Notify Object). 邮递员(event manager)一出现,你的程序中的线程就立即查看邮箱(notify 对象)。

  2. Thread Polling for Events 线程中轮询事件
    The thread in the program periodically checks the mailbox (Notify Object) to see if there is a letter (Event).线程定期的查看邮箱(notify 对象)来看是否有信(event)。                                                        
  3. Thread using mpiNotifyEventWait  线程中使用mpiNotifyEventWait 
    If the thread in the program does not check the mailbox (Notify object), it will start to fill up with letters. The mail carrier (Event Manager) keeps stuffing more letters into the mailbox and figures that you will eventually check it. If the thread calls an mpiNotifyEventWait(...), it checks the mailbox. But, it can only check one letter at a time。如果程序中的线程不检查邮箱(notify对象),邮箱会填满邮件。邮递员(event manager)持续往邮箱加信,他以为你最终会查看邮箱的。如果线程调用了 mpiNotifyEventWait(...),它会检查邮箱。但是一次只看一封信。
  4. Thread using mpiNotifyEventFlush 线程中使用mpiNotifyEventFlush
    If the thread in the program does not check the mailbox (Notify object), it will start to fill up with letters. The mail carrier (Event Manager) keeps stuffing more letters into the mailbox and figures that you will eventually empty it. If the thread calls mpiNotifyEventFlush(...), mail carrier empties the mailbox and throws all the letters in the trash.如果程序中的线程没有检查邮箱(notify对象),邮箱会逐渐的变满。邮递员(event manager)持续的网邮箱里加邮件,他认为你最终会清空它。如果线程调用mpiNotifyEventFlush(...),邮递员会清空邮箱,并把所有的信扔进垃圾箱。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值