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.

Constructors

this
this(Flag!"daemon" daemon)
Undocumented in source.

Members

Functions

close
void close()
Undocumented in source. Be warned that the author may not have intended to support it.
runAsync
void runAsync(Dg dg)
Undocumented in source. Be warned that the author may not have intended to support it.
runWait
void runWait(Dg dg)
Undocumented in source. Be warned that the author may not have intended to support it.

Inherited Members

From TcpConnection

connect
alias connect = SocketConnection.connect
Undocumented in source.
connect
void connect(string host, ushort port)

Start establishing a connection.

Examples

void onConnect(TcpConnection socket)
{
	auto anchor = new ThreadAnchor;
	new Thread({
		string s = readln();
		anchor.runAsync({
			socket.send(s);
			socket.disconnect();
		});
	}).start();
}

Meta