C++ Logo

std-proposals

Advanced search

Re: Signals & Slots

From: Matthew Woehlke <mwoehlke.floss_at_[hidden]>
Date: Fri, 23 Jul 2021 11:27:58 -0400
On 7/23/21 10:39 AM, Andrey Semashev via Std-Proposals wrote:
> On 7/23/21 4:27 PM, Matthew Woehlke wrote:
>> While there is some overlap, signals and callbacks also differ
>> significantly. *Callbacks* are inherently synchronous; that is, it is
>> not unusual for a callback to perform some action that the issuing
>> entity depends on. This also implicitly means it is difficult to have
>> multiple callbacks for the same event. Callbacks, you might say, are
>> *proactive*.
>>
>> Signals are inherently *reactive* and asynchronous. An event occurs, and
>> some other code may *or may not*, at some point in time, react to that
>> event. *Even within a single thread* is is conceptually not the case
>> that this reaction must occur immediately. Many-to-many connections are
>> thus a non-issue, because the entity issuing the event *does not care*
>> whether anything is done with that event.
>
> That's definitely not my understanding of what signals are. In my
> understanding, a signal is a generalization of a function call - instead
> of a single target function call, a signal may have multiple targets and
> aggregates the results into one final result. In addition, signals
> typically allow to abstract away the caller and the callees. This isn't
> a distinctive feature though, since the same is possible with regular
> function calls.
>
> (A)synchronicity and thread locality of the call is an entirely separate
> and orthogonal aspect of the call. Both regular functions and signals
> can be invoked asynchronously and across threads, and signals are not
> inherently asynchronous.
>
>> It is *possible* to implement synchronous connections in Qt, but it is
>> somewhat awkward and IME virtually never done.
>
> I'm not talking about specifically Qt. In fact, I don't have much
> experience with Qt to begin with.> [...] I disagree that
> asynchronicity is an inherent feature of signals. We surely have seen
> successful implementations of the concept that are synchronous.
So, basically, the feature the OP is asking for, which I agree would be
interesting, is not the feature you have in mind. The OP and I *are*
talking about Qt-style signals specifically. (At least, that seems to be
implied by the original message.)

-- 
Matthew

Received on 2021-07-23 10:28:00