Hacker News new | past | comments | ask | show | jobs | submit login

Yeah this confused me too. Not sure what made them think this resembles a latch. A latch only has 2 states, not 2^n states.



The full name is typically CountDownLatch [0]. The latch still has 2 states, closed and open. It's just that it doesn't open until everyone is ready.

[0] https://docs.oracle.com/en/java/javase/15/docs/api/java.base...


That's like saying every integer has 2 states, zero and nonzero. I'm talking states in the computer science sense, not in the "what I prefer to look at" sense. These have 2^n states, whether you choose to care about them or not.

Just because Java calls it something that doesn't mean it is "typically" called that thing.


Representing it as a "state machine" it would still have only 2 states. Open and closed.

I personally "prefer to look at" integers as not having state.

> Just because Java calls it something that doesn't mean it is "typically" called that thing.

It's only been there since 2004 and is named the same in C#


> Representing it as a "state machine" it would still have only 2 states. Open and closed.

No. There are lots of "open" states with different counter values. That you choose to call them all "open" and not observe the differences doesn't change this. It sounds like you've never studied state machines, so I recommend reading up on them; here's a starting point: https://en.wikipedia.org/wiki/State_(computer_science)#Finit...

> It's only been there since 2004 and is named the same in C#

No it's not... where did you get this? C# has CountdownEvent and Barrier. It's not called "latch".

And, for that matter, OpenMP also has #pragma omp barrier since 1998... https://www.openmp.org/wp-content/uploads/cspec10.pdf#page=2...

There's no point continuing this argument so let's just leave it here.


Please avoid swipes in your comments like "It sounds like you've never studied state machines", "where did you get this?" and "There's no point continuing this argument so let's just leave it here". They invariably land with much more force on the other person than you intend, and this leads to much worse threads. It's easy to understand see how this post would turn into a provocation.

https://news.ycombinator.com/newsguidelines.html


> There's no point continuing this argument so let's just leave it here.

Yeah cause you're insufferable.


Ouch, please don't cross into personal attack, regardless of how annoying another comment is or you feel it is! We ban accounts that do that. Fortunately your comment history looks like a good one otherwise. If you wouldn't mind reviewing https://news.ycombinator.com/newsguidelines.html and sticking to the rules when posting here, we'd be grateful.


It makes sense when compared against flip-flop circuit https://www.geeksforgeeks.org/difference-between-flip-flop-a...

Most importantly, latch is level-triggered, just like the synchronization primitive.


latches can be edge or level triggered. The important concept is that once they are triggered, they latch the input value, and maintain it after the input has disappeared.


That's what std::latch does... Once triggered it's always triggered. Same as Java's CountDownLatch


The thing is, pretty much every object you work with in your programming language latches the most recently stored value in it. The machine is built on latching as a fundamental block.

A simple mutex latches open when you unlock it, and then latches locked when something locks it again.


No, I mean, a std::latch cannot be reset. It's a one-direction one-use toggle. There's no unlocking or relocking. There's no "again" to it.


Latches can be reset; so bad metaphor on that count also.

Something that triggers, flips state and cannot be reset might be called a "fuse".

That could work here in another way: since there is a count-down, that's like a dynamite fuse burning.


> It makes sense when compared against flip-flop circuit

It doesn't to me... I'm not following unfortunately.

Barriers are level-triggered too. Like, physical ones. Push with enough force against a barrier and it'll break down.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: