[go: up one dir, main page]

|
|
Log in / Subscribe / Register

C++ not Turing Complete?

C++ not Turing Complete?

Posted Dec 11, 2022 19:40 UTC (Sun) by Wol (subscriber, #4433)
In reply to: C++ not Turing Complete? by gmatht
Parent article: Rust support coming to GCC

The other thing that puzzles me ... how do you write an event handler without an infinite loop?

Loop, wait for an event, handle or pass off, repeat.

The whole point of it is you're meant to loop indefinitely ...

Cheers,
Wol


to post comments

C++ not Turing Complete?

Posted Dec 11, 2022 20:10 UTC (Sun) by ABCD (subscriber, #53650) [Link]

So long as you make "forward progress" inside that loop, you are fine. The problems only arise if you don't do one of the following:

  • terminate [the thread],
  • make a call to a library I/O function,
  • perform an access through a volatile glvalue, or
  • perform a synchronization operation or an atomic operation.

I would presume that in your event handler, you are going to wait for an event somehow, which would require that you either call a library I/O function to see if you have events (and/or get the event information), access a volatile glvalue (in the case of a hardware event handler with memory-mapped I/O, for instance), or perform a synchronization operation or atomic operation (which is probably needed for thread safety if the events are being posted by another thread in the same application). In any of these cases, you have made forward progress in some manner, using the standard's definition of "forward progress".


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds