保证信号量顺序? [英] Guaranteed semaphore order?

查看:149
本文介绍了保证信号量顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.NET Semaphore类的文档指出:

The documentation for the .NET Semaphore class states that:

没有保证的顺序(例如FIFO或LIFO),阻止的线程在该顺序中进入信号量.

There is no guaranteed order, such as FIFO or LIFO, in which blocked threads enter the semaphore.

在这种情况下,如果我要保证订单(FIFO或LIFO),我有什么选择?这是不容易做到的吗?我需要编写自己的信号量吗?我认为那会相当先进吗?

In this case, if I want a guaranteed order (either FIFO or LIFO), what are my options? Is this something that just isn't easily possible? Would I have to write my own Semaphore? I assume that would be pretty advanced?

谢谢

史蒂夫

推荐答案

请参见

FifoSemaphore的工作原理与普通的Semaphore完全相同,但是还可以保证令牌以获取者设法获取内部锁的顺序提供给获取者. FifoSemaphore的用法与Semaphore相同.

The FifoSemaphore works exactly like a normal Semaphore but also guarantees that tokens are served out to acquirers in the order that they manage to acquire the internal lock. The usage of a FifoSemaphore is identical to a Semaphore.

这篇关于保证信号量顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆