ThreadAnchor

An object which allows calling a function in a different thread. Create ThreadAnchor in the main thread (the thread in which the code will run in), and then call runWait or runAsync from a different thread.

The main thread must be running an unblocked ae.net.asockets event loop.

final
class ThreadAnchor : TcpConnection {}

Inherited Members

From TcpConnection

onError
void onError(string reason)

Called when an error occurs on the socket.

connect
void connect(string host, ushort port)
void connect(AddressInfo[] addresses)

Start establishing a connection.

Examples

1 void onConnect(TcpConnection socket)
2 {
3 	auto anchor = new ThreadAnchor;
4 	new Thread({
5 		string s = readln();
6 		anchor.runAsync({
7 			socket.send(s);
8 			socket.disconnect();
9 		});
10 	}).start();
11 }

Meta