fawkes::FawkesNetworkClientSendThread Class Reference
[Fawkes Network Communication]

Fawkes network client send thread. More...

Inheritance diagram for fawkes::FawkesNetworkClientSendThread:

[legend]
List of all members.

Public Member Functions

 FawkesNetworkClientSendThread (StreamSocket *s, FawkesNetworkClient *parent)
 Constructor.
 ~FawkesNetworkClientSendThread ()
 Destructor.
virtual void once ()
 Execute an action exactly once.
virtual void loop ()
 Code to execute in the thread.
void force_send ()
 Force sending of messages.
void enqueue (FawkesNetworkMessage *message)
 Enqueue message to send and take ownership.

Protected Member Functions

virtual void run ()
 Stub to see name in backtrace for easier debugging.

Detailed Description

Fawkes network client send thread.

Spawned by the FawkesNetworkClient to handle outgoing traffic.

Author:
Tim Niemueller

Definition at line 65 of file client.cpp.


Constructor & Destructor Documentation

fawkes::FawkesNetworkClientSendThread::FawkesNetworkClientSendThread ( StreamSocket s,
FawkesNetworkClient parent 
) [inline]

Constructor.

Parameters:
s client stream socket
parent parent FawkesNetworkClient instance

Definition at line 73 of file client.cpp.

fawkes::FawkesNetworkClientSendThread::~FawkesNetworkClientSendThread (  )  [inline]

Destructor.

Definition at line 86 of file client.cpp.


Member Function Documentation

void fawkes::FawkesNetworkClientSendThread::enqueue ( FawkesNetworkMessage message  )  [inline]

Enqueue message to send and take ownership.

This method takes ownership of the message. If you want to use the message after enqueing you must reference:

 message->ref();
 send_slave->enqueue(message);
 // message can now still be used
Without extra referencing the message may not be used after enqueuing.
Parameters:
message message to send

Definition at line 150 of file client.cpp.

References fawkes::Mutex::lock(), fawkes::Mutex::unlock(), and fawkes::Thread::wakeup().

Referenced by fawkes::FawkesNetworkClient::enqueue(), and fawkes::FawkesNetworkClient::enqueue_and_wait().

void fawkes::FawkesNetworkClientSendThread::force_send (  )  [inline]

Force sending of messages.

All messages are sent out immediately, if loop is not running already anyway.

Definition at line 131 of file client.cpp.

References loop(), fawkes::Thread::loop_mutex, fawkes::Mutex::try_lock(), and fawkes::Mutex::unlock().

Referenced by fawkes::FawkesNetworkClient::disconnect().

virtual void fawkes::FawkesNetworkClientSendThread::loop (  )  [inline, virtual]

Code to execute in the thread.

Implement this method to hold the code you want to be executed continously. If you do not implement this method, the default is that the thread will exit. This is useful if you choose to only implement once().

Reimplemented from fawkes::Thread.

Definition at line 105 of file client.cpp.

References fawkes::FawkesNetworkClient::connected(), fawkes::FawkesNetworkClient::connection_died(), fawkes::Thread::exit(), fawkes::Mutex::lock(), fawkes::FawkesNetworkTransceiver::send(), and fawkes::Mutex::unlock().

Referenced by force_send().

virtual void fawkes::FawkesNetworkClientSendThread::once (  )  [inline, virtual]

Execute an action exactly once.

This code is executed once and only once right after the thread is started before loop() is called. This is useful if you want to implement an one-shot background job. Just implement once() and leave once() untouched. Start the thread and detach it and it will just do its job and then die automatically. If you use set_delete_on_exit(true) even the Thread instance will be automatically deleted.

Reimplemented from fawkes::Thread.

Definition at line 100 of file client.cpp.

References fawkes::FawkesNetworkClient::set_send_slave_alive().

virtual void fawkes::FawkesNetworkClientSendThread::run (  )  [inline, protected, virtual]

Stub to see name in backtrace for easier debugging.

See also:
Thread::run()

Reimplemented from fawkes::Thread.

Definition at line 160 of file client.cpp.

References fawkes::Thread::run().


The documentation for this class was generated from the following file:
Generated on Tue Feb 22 13:31:40 2011 for Fawkes API by  doxygen 1.4.7