Block and process events until a signal is emitted. More...
#include <QxtSignalWaiter>
Inherits QObject.
In many cases, writing code that assumes certain actions are synchronous is considerably simpler than breaking your function into multiple blocks and using signals and slots to connect them all. Using this class, QSignalWaiter::wait will block until a certain signal is emitted and then return. The return value is true if the signal was caught, or false if a user-specified timeout elapses before catching the signal.
Bug
QxtSignalWaiter is not reentrant. In particular, only one QxtSignalWaiter object per thread can be safely waiting at a time. If a second QxtSignalWaiter is used while the first is waiting, the first will not return until the second has timed out or successfully caught its signal.
Constructs a QxtSignalWaiter that will wait for sender::signal() to be emitted. QxtSignalWaiter objects are intended to be created on the stack, therefore no parent parameter is accepted.
Blocks the current function until sender::signal() is emitted. If msec is not -1, wait() will return before the signal is emitted if the specified number of milliseconds have elapsed. Returns true if the signal was caught, or false if the timeout elapsed. Note that wait() may continue to block after the signal is emitted or the timeout elapses; the function only guarantees that it will not return BEFORE one of these conditions has occurred. This function is not reentrant.
This is an overloaded function provided for convenience. This version can be invoked without first instantiating a QxtSignalWaiter object.
Signals a waiting object to stop blocking because the desired signal was emitted. QxtSignalWaiter::hasCapturedSignal() will return true after this slot is invoked. Use this slot to allow QxtSignalWaiter to wait for the first of multiple signals.
Signals a waiting object to stop blocking because the timeout has elapsed. QxtSignalWaiter::hasCapturedSignal() will return false after this slot is invoked. Use this slot to allow QxtSignalWaiter to be interrupted for reasons other than a timeout.
| Copyright © 2007 Qxt Foundation | Trademarks | Qt Extension Library 0.4 |