Readit News logoReadit News
dkjaudyeqooe commented on Hacking Coroutines into C   wiomoc.de/misc/posts/hack... · Posted by u/jmillikin
adinisom · a month ago
My favorite trick in C is a light-weight Protothreads implemented in-place without dependencies. Looks something like this for a hypothetical blinky coroutine:

  typedef struct blinky_state {
    size_t pc;
    uint64_t timer;
    ... variables that need to live across YIELDs ...
  } blinky_state_t;
  
  blinky_state_t blinky_state;
  
  #define YIELD() s->pc = __LINE__; return; case __LINE__:;
  void blinky(void) {
    blinky_state_t *s = &blinky_state;
    uint64_t now = get_ticks();
    
    switch(s->pc) {
      while(true) {
        turn_on_LED();
        s->timer = now;
        while( now - s->timer < 1000 ) { YIELD(); }
        
        turn_off_LED();
        s->timer = now;
        while( now - s->timer < 1000 ) { YIELD(); }
      }
    }
  }
  #undef YIELD
Can, of course, abstract the delay code into it's own coroutine.

Your company is probably using hardware containing code I've written like this.

What's especially nice that I miss in other languages with async/await is ability to mix declarative and procedural code. Code you write before the switch(s->pc) statement gets run on every call to the function. Can put code you want to be declarative, like updating "now" in the code above, or if I have streaming code it's a great place to copy data.

dkjaudyeqooe · a month ago
A cleaner, faster way to implement this sort of thing is to use the "labels as values" extension if using GCC or Clang []. It avoids the switch statement and associated comparisons. Particularly useful if you're yielding inside nested loops (which IMHO is one of the most useful applications of coroutines) or switch statements.

[] https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html

dkjaudyeqooe commented on Bulgaria to join euro area on 1 January 2026   ecb.europa.eu//press/pr/d... · Posted by u/toomuchtodo
mc32 · 2 months ago
Also the experience of Greece not too far back and the austerity imposed by Germany is not quite forgotten. Varoufakis[1] can attest to its severity. The Greeks voted against it but Germany imposed its will.

[1]https://jacobin.com/2025/07/yanis-varoufakis-on-the-legacy-o...

dkjaudyeqooe · 2 months ago
This is nonsense. Not mentioned is that Greece has borrowed excessively and had defaulted on its loans. A bailout was organized by the EU and IMF with terms that Greece had every opportunity to reject. No one forced anything on Greece. The referendum was not binding and political theater for the government of the time.

That Greece accepted the terms reflected the reality that the alternative was much worse and would have caused great suffering for Greeks.

Deleted Comment

dkjaudyeqooe commented on The economics behind "Basic Economy" – A masterclass in price discrimination   blog.getjetback.com/the-e... · Posted by u/bdev12345
tonyedgecombe · 2 months ago
>Airlines are an abusive oligopoly there

>Average fares are skewed by low cost carriers entering the market.

dkjaudyeqooe · 2 months ago
The large carriers, created through mergers that should never have been allowed, have the most popular routes locked up through ownership of landing/takeoff slots and similar. On those routes, fares have substantially increased due to a lack of competition.

The low cost carriers business model is to fly new routes (to secondary airports if required) at low prices, often creating new demand (Breeze is a classic example of this).

The math is very straight forward if you consider what each group is doing in the market.

dkjaudyeqooe commented on The economics behind "Basic Economy" – A masterclass in price discrimination   blog.getjetback.com/the-e... · Posted by u/bdev12345
nickff · 2 months ago
The airline industry is famously unprofitable; it is commonly said that on net, the sum total of airlines have made $0 over the course of their history. It is true that there are periods where they do make a profit, but these periods are offset by times when they make massive losses (such as during COVID, after the Great Recession, and after 9/11).
dkjaudyeqooe · 2 months ago
Globally, big airlines seem to be doing fine:

https://www.aerotime.aero/articles/most-profitable-airlines

I think there are lots of airlines that are propped up by governments that lose money leading to the meme you're quoting. Many industries were affected by the events you quoted, those sorts of things aren't specific to airlines.

dkjaudyeqooe commented on The economics behind "Basic Economy" – A masterclass in price discrimination   blog.getjetback.com/the-e... · Posted by u/bdev12345
burlesona · 2 months ago
Airfare in the US costs less today than it did in the 90s, adjusted for inflation: https://www.bts.gov/newsroom/2024-annual-average-domestic-ai...
dkjaudyeqooe · 2 months ago
Average airfare isn't a useful stat in this respect. What would be useful is comparing fares for individual routes over the years, which would tell a different story.

Average fares are skewed by low cost carriers entering the market.

dkjaudyeqooe commented on National Archives at College Park, MD, will become a restricted federal facility   archives.gov/college-park... · Posted by u/LastTrain
XorNot · 2 months ago
This is how Russia works. This is why the Russian government does what it does and why the people let it happen.

Because obviously nothing can ever change, so don't even try. How silly of of you citizen, to imagine even trying to fix corruption.

dkjaudyeqooe · 2 months ago
That's not what I'm talking about. It's the notion that if you get the corrupt to justify their actions that you'll somehow avoid corruption.

Fixing corruption involves people refusing to put up with corruption.

dkjaudyeqooe commented on National Archives at College Park, MD, will become a restricted federal facility   archives.gov/college-park... · Posted by u/LastTrain
goda90 · 2 months ago
Every aspect of government should provide the public with rationale for its actions unless providing that rationale is an actual threat to national security or an individual's freedoms. And any time they can't provide rationale for those reasons, an independent agency should review them confidentially. You can't have government by the people, for the people, of the people without accountability.
dkjaudyeqooe · 2 months ago
This is the sort of bureaucratic nonsense people actually rail against.

You're assuming you'd get something truthful or informative out of that process, when in reality you'll get the opposite due to the inherit (dis)incentives.

dkjaudyeqooe commented on National Archives at College Park, MD, will become a restricted federal facility   archives.gov/college-park... · Posted by u/LastTrain
AnimalMuppet · 2 months ago
I dunno. I'm very much not a Trump fan, but I don't see how restricting access to "national information" would help him. And if it would, how does restricting access to one of them help him?

I could more see this as being just random action without any real purpose, or aimed at petty revenge on someone, or something.

dkjaudyeqooe · 2 months ago
More broadly, ignorance and stupidity amongst the general population benefit some politicians.

u/dkjaudyeqooe

KarmaCake day6655November 30, 2020View Original