#include <thread_tunnel.h>

Public Types | |
| enum | Mode { NewThread, CurrentThread, SingleThread } |
Public Member Functions | |
| ThreadTunnel (Dispatcher &disp, Mode mode=NewThread) | |
| Dispatcher & | dispatcher () |
| virtual void | send (Callback *cb, bool sync=false) |
| virtual bool | in_sync_callback () |
| virtual void | drain () |
Classes | |
| class | FatalError |
| Exception class. More... | |
This tunnel is implemented using a pipe to transfer callbacks from one thread to another. It also has a single-threaded mode in which it uses the pipe anyway. This can be used to code nearly non-blocking UIs without the use of threads.
Execution mode of the ThreadTunnel.
| SigCX::ThreadTunnel::ThreadTunnel | ( | Dispatcher & | disp, | |
| Mode | mode = NewThread | |||
| ) |
Constructor.
| disp | Dispatcher to use for the destination thread (working thread, the thread where the callbacks are executed). | |
| mode | Working mode of the dispatcher. |
| Dispatcher& SigCX::ThreadTunnel::dispatcher | ( | ) | [inline] |
Get the destination thread dispatcher.
| virtual void SigCX::ThreadTunnel::send | ( | Callback * | cb, | |
| bool | sync = false | |||
| ) | [virtual] |
Send a callback to the other side.
| cb | Callback to be executed on the other side of the tunnel. | |
| sync | If true, this thread is suspended until the callback has finished execution. |
Implements SigCX::Tunnel.
| virtual bool SigCX::ThreadTunnel::in_sync_callback | ( | ) | [virtual] |
Check if tunnel is executing a synchronous callback.
true if a synchronous callback is in execution. Implements SigCX::Tunnel.
| virtual void SigCX::ThreadTunnel::drain | ( | ) | [virtual] |
Drain the tunnel.
Any callbacks in the tunnel are cancelled. This is intended to be called at the destination end of the tunnel.
Implements SigCX::Tunnel.
1.5.5