Djikstra计算c#中的信号量供您查看 [英] Djikstra counting semaphore in c# for your review

查看:67
本文介绍了Djikstra计算c#中的信号量供您查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是链接。如果您发现问题或想到某项功能,请发布

回复或发送电子邮件。干杯!
http://www.mvptools.com/ doco / csharp / ... redjikstra.htm


-

William Stacey,MVP

Here is the link. If you find an issue or think of a feature, please post a
reply or send an email. Cheers!
http://www.mvptools.com/doco/csharp/...redjikstra.htm

--
William Stacey, MVP

推荐答案

" William Stacey [MVP]" < ST *********** @ mvps.org>在消息中写道

新闻:OD ************** @ TK2MSFTNGP09.phx.gbl ...
"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:OD**************@TK2MSFTNGP09.phx.gbl...
这是链接。如果您发现问题或想到某项功能,请在回复中发送
或发送电子邮件。干杯!
http://www.mvptools.com/ doco / csharp / ... redjikstra.htm

-
William Stacey,MVP
Here is the link. If you find an issue or think of a feature, please post a reply or send an email. Cheers!
http://www.mvptools.com/doco/csharp/...redjikstra.htm

--
William Stacey, MVP




我'我还在进一步检查,但这里有两个即时评论:


*这个名字叫Dijkstra,而不是Djikstra(我说的是荷兰语,所以我知道为什么)

*我会让Semaphore上课密封。


我稍后会检查其余部分。


干杯,

---

Tom Tempelaere



I''m still checking further, but here a two instant remarks:

* The name is Dijkstra, not Djikstra (I''m dutch speaking, so I know why)
* I would make the class Semaphore sealed.

I''m going to check the rest later.

Cheers,
---
Tom Tempelaere


" William Stacey [MVP]" < ST *********** @ mvps.org>在消息中写道

新闻:OD ************** @ TK2MSFTNGP09.phx.gbl ...
"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:OD**************@TK2MSFTNGP09.phx.gbl...
这是链接。如果您发现问题或想到某项功能,请在回复中发送
或发送电子邮件。干杯!
http://www.mvptools.com/ doco / csharp / ... redjikstra.htm

-
William Stacey,MVP
Here is the link. If you find an issue or think of a feature, please post a reply or send an email. Cheers!
http://www.mvptools.com/doco/csharp/...redjikstra.htm

--
William Stacey, MVP




William,


关于Count属性。我认为这是一个危险的财产。在检查计数后获取时,

计数不保证相同。

在某些情况下可能是优化,但我看不到它。


所以也许你不应该锁定Count的实现。您认为

是什么?


干杯,

---

Tom Tempelaere



William,

About the Count property. I think this is a dangerous property to use. The
count is not guaranteed to be same when acquiring after checking the count.
It might be an optimization in some cases, but I don''t see the use for it.

So perhaps then you shouldn''t lock in the implementation of Count. What do
you think?

Cheers,
---
Tom Tempelaere


" William Stacey [MVP]" < ST *********** @ mvps.org>在消息中写道

新闻:OD ************** @ TK2MSFTNGP09.phx.gbl ...
"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:OD**************@TK2MSFTNGP09.phx.gbl...
这是链接。如果您发现问题或想到某项功能,请在回复中发送
或发送电子邮件。干杯!
http://www.mvptools.com/ doco / csharp / ... redjikstra.htm

-
William Stacey,MVP
Here is the link. If you find an issue or think of a feature, please post a reply or send an email. Cheers!
http://www.mvptools.com/doco/csharp/...redjikstra.htm

--
William Stacey, MVP




William,


您的AcquireAll方法会尝试单独获取每个插槽。也许你可以优化并获得每次迭代可用的所有插槽,直到你获得所有插槽的



加上毫秒时间超时欺骗,因为最大时间可以是
(maxSlots *毫秒时间)

来获得所有插槽。


我注意到存在a

发布(int n)

方法但不是

获取(int n)

方法。这是意图吗?


如果您要编写Acquire(int n)方法,您可以实现

Acquire()as Acquire(1)



AcquireAll()as Acquire(maxCount)


干杯,

---

Tom Tempelaere



William,

Your AcquireAll method tries to acquire each slot seperately. Perhaps you
could optimize and acquire all slots available each iteration until you
acquired all slots.

Plus the millisecondsTimeout is deceiving, because the max time could be
( maxSlots * millisecondsTimeout )
to acquire all slots.

I noticed that there exists a
Release( int n )
method but not an
Acquire( int n )
method. Is this the intention?

If you would write the Acquire( int n ) method, you could implement
Acquire() as Acquire( 1 )
and
AcquireAll() as Acquire( maxCount )

Cheers,
---
Tom Tempelaere


这篇关于Djikstra计算c#中的信号量供您查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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