Discussion:
z-order for Qt's signals and slots
(too old to reply)
Sathishkumar Duraisamy
2011-11-23 05:21:17 UTC
Permalink
Hi all,

By definition, the order by which the signals and slots is called is
undefined but for each signals and slots connection, slots will be
called for its signals.

Why can't we have z-order for signals and slots, taking control for of
order the slots will be called. For some peculiar situation, that the
programmer feels it would be best if it is called the slots after
finishing all other slots. Or is there way to achieve the same?

--
Regards,
Sathishkumar D
http://flowersopenlab.weebly.com/
Bo Thorsen
2011-11-23 06:45:16 UTC
Permalink
Post by Sathishkumar Duraisamy
Hi all,
By definition, the order by which the signals and slots is called is
undefined but for each signals and slots connection, slots will be
called for its signals.
Why can't we have z-order for signals and slots, taking control for of
order the slots will be called. For some peculiar situation, that the
programmer feels it would be best if it is called the slots after
finishing all other slots. Or is there way to achieve the same?
If you need ordering, call the functions directly. Sometimes I see cases
for this too, but the interface for controlling it would be annoying,
and it's rarely necessary. So my POV is that you should just use a
different way if you need ordered calls.

Bo Thorsen,
Fionia Software.
--
Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
Frans Klaver
2011-11-23 06:54:42 UTC
Permalink
Post by Bo Thorsen
Post by Sathishkumar Duraisamy
Why can't we have z-order for signals and slots, taking control for of
order the slots will be called. For some peculiar situation, that the
programmer feels it would be best if it is called the slots after
finishing all other slots. Or is there way to achieve the same?
If you need ordering, call the functions directly. Sometimes I see cases
for this too, but the interface for controlling it would be annoying,
and it's rarely necessary. So my POV is that you should just use a
different way if you need ordered calls.
I would even take this further, and say that if you needed z-ordering in
signal/slot connections, you're missing the entire point of signals and
slots. If you rely on a certain order, you have two options. Either your
code either isn't modular enough (A::x() has to be called before B::y()
usually signals that), or you should take the approach proposed by Bo
(A::z() { x(); y(); }.

Cheers,
Frans
Andre Somers
2011-11-23 06:58:19 UTC
Permalink
Post by Sathishkumar Duraisamy
Hi all,
By definition, the order by which the signals and slots is called is
undefined but for each signals and slots connection, slots will be
called for its signals.
That is no longer true. It is now documented that slots will be called
in the order they are connected.
Post by Sathishkumar Duraisamy
Why can't we have z-order for signals and slots, taking control for of
order the slots will be called. For some peculiar situation, that the
programmer feels it would be best if it is called the slots after
finishing all other slots. Or is there way to achieve the same?
As Bo sais: an API for that would be annoying at best, for something you
need only rarely. Why not create more than one signal that you emit in
order, or just make the object doing the processing emit a signal
itself, and connect to that for your next step processing.

André
Giuseppe D'Angelo
2011-11-23 11:52:35 UTC
Permalink
On 23 November 2011 05:21, Sathishkumar Duraisamy
Post by Sathishkumar Duraisamy
Hi all,
By definition, the order by which the signals and slots is called is
undefined but for each signals and slots connection, slots will be
called for its signals.
For the sake of the argument, that's not completely true -- slots are
guaranteed to be called in the order they have been connected to the
signal.
--
Giuseppe D'Angelo
Atlant Schmidt
2011-11-23 12:15:09 UTC
Permalink
Post by Giuseppe D'Angelo
For the sake of the argument, that's not completely true --
slots are guaranteed to be called in the order they have
been connected to the signal.
I believe that's only true for locally-connected slots
(where the emission of a signal simply becomes a well-
hidden function call). But once you involve a network,
all bets on ordering are off.

Atlant

-----Original Message-----
From: interest-bounces+aschmidt=***@qt-project.org [mailto:interest-bounces+aschmidt=***@qt-project.org] On Behalf Of Giuseppe D'Angelo
Sent: Wednesday, November 23, 2011 06:53
To: Sathishkumar Duraisamy
Cc: ***@qt-project.org
Subject: Re: [Interest] z-order for Qt's signals and slots

On 23 November 2011 05:21, Sathishkumar Duraisamy
Post by Giuseppe D'Angelo
Hi all,
By definition, the order by which the signals and slots is called is
undefined but for each signals and slots connection, slots will be
called for its signals.
For the sake of the argument, that's not completely true -- slots are
guaranteed to be called in the order they have been connected to the
signal.
--
Giuseppe D'Angelo
_______________________________________________
Interest mailing list
***@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Click https://www.mailcontrol.com/sr/rN2cE1EomvjTndxI!oX7UsdpzMR7Bo2KtxIHwmapinxAzSy711vj151URNZkVeUOO1VrjchtaiwsWPB8dn7asg== to report this email as spam.

This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.

Thank you.

Please consider the environment before printing this email.
Giuseppe D'Angelo
2011-11-23 12:34:30 UTC
Permalink
Post by Giuseppe D'Angelo
For the sake of the argument, that's not completely true --
slots are guaranteed to be called in the order they have
been connected to the signal.
 I believe that's only true for locally-connected slots
 (where the emission of a signal simply becomes a well-
 hidden function call). But once you involve a network,
 all bets on ordering are off.
Well, that's true for direct connections. Queued connections will be
invoked at an unpredictable time in the receiver object's thread. What
do you mean with "involve a network"?

Cheers,
--
Giuseppe D'Angelo
Jason H
2011-11-23 14:41:52 UTC
Permalink
Haha, a little leakage there. You must be doing multi-threaded networking because it is not the network that makes the ordering impossible, it is the threading. Because your thread execution can happen according to your scheduler (and linux has many) and the i/o blocking for a thread, the order is undefined between threads.

Direct connections are maintained in a list and exhibit stability in accordance with the list operations. However do not exploit this.

The tips given - use finer grained emits and group multiple sequential functions in a single function is the way to go. If you are doing something with a high degree of synchronicity, and are not doing anything else, you can use the QxtSignalWaiter class to serialize stuff.



________________________________
From: Atlant Schmidt <***@dekaresearch.com>
To: 'Giuseppe D'Angelo' <***@gmail.com>; Sathishkumar Duraisamy <***@gmail.com>
Cc: "***@qt-project.org" <***@qt-project.org>
Sent: Wednesday, November 23, 2011 7:15 AM
Subject: Re: [Interest] z-order for Qt's signals and slots
Post by Giuseppe D'Angelo
For the sake of the argument, that's not completely true --
slots are guaranteed to be called in the order they have
been connected to the signal.
  I believe that's only true for locally-connected slots
  (where the emission of a signal simply becomes a well-
  hidden function call). But once you involve a network,
  all bets on ordering are off.

                            Atlant

-----Original Message-----
From: interest-bounces+aschmidt=***@qt-project.org [mailto:interest-bounces+aschmidt=***@qt-project.org] On Behalf Of Giuseppe D'Angelo
Sent: Wednesday, November 23, 2011 06:53
To: Sathishkumar Duraisamy
Cc: ***@qt-project.org
Subject: Re: [Interest] z-order for Qt's signals and slots

On 23 November 2011 05:21, Sathishkumar Duraisamy
Post by Giuseppe D'Angelo
Hi all,
By definition, the order by which the signals and slots is called is
undefined but for each signals and slots connection, slots will be
called for its signals.
For the sake of the argument, that's not completely true -- slots are
guaranteed to be called in the order they have been connected to the
signal.
--
Giuseppe D'Angelo
_______________________________________________
Interest mailing list
***@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Click https://www.mailcontrol.com/sr/rN2cE1EomvjTndxI!oX7UsdpzMR7Bo2KtxIHwmapinxAzSy711vj151URNZkVeUOO1VrjchtaiwsWPB8dn7asg==  to report this email as spam.

This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.

Thank you.

Please consider the environment before printing this email.
Sathishkumar Duraisamy
2011-11-24 12:18:19 UTC
Permalink
Well, I agree, signals are means of asynchronous way of communication
between objects. Implementing an order of how slots are called, may
change the meaning. Also, it going to rare case or a bug. It should be
fixed in another way.
--
Regards,
Sathishkumar D
http://flowersopenlab.weebly.com/
Konstantin Tokarev
2011-11-23 11:55:41 UTC
Permalink
Post by Sathishkumar Duraisamy
Hi all,
By definition, the order by which the signals and slots is called is
undefined but for each signals and slots connection, slots will be
called for its signals.
Why can't we have z-order for signals and slots, taking control for of
order the slots will be called. For some peculiar situation, that the
programmer feels it would be best if it is called the slots after
finishing all other slots. Or is there way to achieve the same?
Sorry if I misunderstand something, but it's not clear for me how do you define
Z axis here... And what about, e.g., y-order?
--
Regards,
Konstantin
Continue reading on narkive:
Loading...