#include <nnreactor.h>
Inheritance diagram for NewNet::Reactor:

Public Types | |
| typedef Event< long > | Timeout |
| Convenience definition for timeouts. | |
Public Member Functions | |
| Reactor () | |
| Constructor. | |
| void | add (Socket *socket) |
| Add a socket to the reactor. | |
| void | remove (Socket *socket) |
| Remove a socket from the reactor. | |
| void | run () |
| Start the main loop. | |
| void | stop () |
| Stop the main loop. | |
| Timeout::Callback * | addTimeout (long msec, Timeout::Callback *callback) |
| Add a new timeout to the reactor. | |
| template<class ObjectType, typename MethodType> | |
| Timeout::Callback * | addTimeout (long msec, ObjectType *object, MethodType method) |
| Add a new timeout to the reactor. | |
Definition at line 34 of file nnreactor.h.
| typedef Event<long> NewNet::Reactor::Timeout |
A convenience definition for timeout callback. Note: Timeouts aren't actually used as events, bu the Event::Callback class is used to define the callback for a timeout.
Definition at line 73 of file nnreactor.h.
| NewNet::Reactor::Reactor | ( | ) |
Create a new reactor
Definition at line 107 of file nnreactor.cpp.
| void NewNet::Reactor::add | ( | Socket * | socket | ) |
Add a socket to the reactor's watch list so that the socket will be able to receive and process events. Note: stores a RefPtr to the socket object
Definition at line 119 of file nnreactor.cpp.
References NewNet::Socket::reactor(), and NewNet::Socket::setReactor().
| void NewNet::Reactor::remove | ( | Socket * | socket | ) |
Remove a socket from the reactor's watch list. Note: The reactor stores a RefPtr to the socket, if the reactor holds the last reference to the socket, it will get deleted automatically.
Definition at line 137 of file nnreactor.cpp.
References NewNet::Socket::reactor(), and NewNet::Socket::setReactor().
| void NewNet::Reactor::run | ( | ) |
Call this to start the reactor's main loop. The reactor will start listening for events and waiting for timeouts to happen. This method will not return until there are no sockets and timeouts left, or when Reactor::stop() is called.
Definition at line 146 of file nnreactor.cpp.
References NewNet::Socket::SocketConnected, NewNet::Socket::SocketConnecting, NewNet::Socket::SocketDisconnected, NewNet::Socket::SocketDisconnecting, NewNet::Socket::SocketException, NewNet::Socket::SocketListening, NewNet::Socket::SocketUninitialized, NewNet::Socket::StateException, NewNet::Socket::StateReceive, and NewNet::Socket::StateSend.
| void NewNet::Reactor::stop | ( | ) |
Call this to exit the reactor's main loop. Note that the reactor will first process any pending events before exiting.
Definition at line 323 of file nnreactor.cpp.
| NewNet::Reactor::Timeout::Callback * NewNet::Reactor::addTimeout | ( | long | msec, | |
| Timeout::Callback * | callback | |||
| ) |
Add a new timeout callback to the reactor so that the callback will be invoked after approximately msec miliseconds. Note: stores a RefPtr to the callback object.
Definition at line 329 of file nnreactor.cpp.
Referenced by addTimeout().
| Timeout::Callback* NewNet::Reactor::addTimeout | ( | long | msec, | |
| ObjectType * | object, | |||
| MethodType | method | |||
| ) | [inline] |
Add a new timeout callback to the reactor so that the method of the specified object will be invoked after approximately msec miliseconds. Note: stores a RefPtr to the generated callback object.
Definition at line 86 of file nnreactor.h.
References addTimeout(), and NewNet::Event< T >::bind().
1.5.1