Inheritance diagram for os::Looper:
Public Types | |
typedef std::map< int, Handler * > | handler_map |
Public Member Functions | |
Looper (const String &cName, int nPriority=NORMAL_PRIORITY, int nPortSize=DEFAULT_PORT_SIZE) | |
The looper constructor. | |
virtual | ~Looper () |
Looper destructor. | |
void | SetName (const String &cName) |
Rename the looper. | |
String | GetName () const |
Get the loopers name. | |
bool | IsPublic () const |
See if the looper's message port is public. | |
void | SetPublic (bool bPublic) |
Make port public/private. | |
port_id | GetMsgPort () const |
Obtain the low-level message port used by this looper. | |
thread_id | GetThread () const |
Obtain the thread id of the looper thread. | |
proc_id | GetProcess () const |
Obtain the process ID of the loopers thread. | |
status_t | Lock () |
Lock the looper object. | |
status_t | Lock (bigtime_t nTimeout) |
Lock the looper with a timeout. | |
status_t | SafeLock () |
Attempt to lock the looper. | |
status_t | Unlock () |
Unlock the looper. | |
void | SetMutex (Locker *pcMutex) |
Set a custom mutex to be used by the looper. | |
Locker * | GetMutex () const |
Get a pointer to the loopers mutex. | |
int | GetLockCount () const |
Obtain the number of locks held on the looper. | |
thread_id | GetLockingThread () const |
Obtaing the owner of the looper lock. | |
bool | IsLocked () const |
Check if the looper lock is owned by the calling thread. | |
virtual thread_id | Run () |
Start and unlock the looper. | |
int | Wait () const |
Wait for the looper thread to die. | |
status_t | PostMessage (uint32 nCode) |
Deliver a message to the looper. | |
status_t | PostMessage (Message *pcMsg) |
Deliver a message to the looper. | |
status_t | PostMessage (uint32 cCode, Handler *pcHandler, Handler *pcReplyTo=NULL) |
Deliver a message to the looper. | |
status_t | PostMessage (Message *pcMsg, Handler *pcHandler, Handler *pcReplyTo=NULL) |
Deliver a message to the looper. | |
void | SpoolMessages () |
Drain the low-level message port. | |
Message * | GetCurrentMessage () const |
Obtain the message currently being processed. | |
Message * | DetachCurrentMessage () |
Steal the current message. | |
virtual void | DispatchMessage (Message *pcMessage, Handler *pcHandler) |
The loopers message handling callback. | |
virtual void | Started () |
Called by the looper thread before entering the message loop. | |
virtual bool | Idle () |
Hook called each time the message queue is drained. | |
MessageQueue * | GetMessageQueue () const |
Obtain the internal message queue used by the looper. | |
virtual bool | OkToQuit () |
Check if it is ok to break the loop. | |
virtual void | Quit () |
Unconditionally terminate the looper. | |
void | Terminate () |
Unconditionally terminate the looper. | |
void | AddTimer (Handler *pcTarget, int nID, bigtime_t nTimeout, bool bOneShot=true) |
Add a timer to the looper. | |
bool | RemoveTimer (Handler *pcTarget, int nID) |
Delete a timer. | |
const handler_map & | GetHandlerMap () const |
Get the internal handler list. | |
void | AddHandler (Handler *pcHandler) |
Add a handler to the looper. | |
bool | RemoveHandler (Handler *pcHandler) |
Remove a handler previously added by AddHandler(). | |
Handler * | FindHandler (const String &cName) const |
Search the looper for a named handler. | |
int | GetHandlerCount () const |
Obtain the count of handlers added to this looper. | |
void | SetDefaultHandler (Handler *pcHandler) |
Set the default target for incomming messages. | |
Handler * | GetDefaultHandler () const |
Obtain the default handler for the looper. | |
void | AddCommonFilter (MessageFilter *pcFilter) |
void | RemoveCommonFilter (MessageFilter *pcFilter) |
const MsgFilterList & | GetCommonFilterList () const |
Static Public Member Functions | |
static Looper * | GetLooperForThread (thread_id hThread) |
Protected Member Functions | |
bool | FilterMessage (Message *pcMsg, Handler **ppcTarget, std::list< MessageFilter * > *pcFilterList) |
Friends | |
class | Application |
class | Messenger |
class | NodeMonitor |
class | Window |
Classes | |
class | Private |
struct | TimerNode |
typedef std::map<int,Handler*> os::Looper::handler_map |
Looper::Looper | ( | const String & | cName, | |
int | nPriority = NORMAL_PRIORITY , |
|||
int | nPortSize = DEFAULT_PORT_SIZE | |||
) |
pzName | Passed down to the Handler::Handler() constructor. | |
nPriority | Stored for later usage as the looper-thread priority. | |
nPortSize | Maximum number of pending messages. |
Looper::~Looper | ( | ) | [virtual] |
void Looper::SetName | ( | const String & | cName | ) |
cName | The new looper name |
Reimplemented from os::Handler.
String Looper::GetName | ( | ) | const |
Reimplemented from os::Handler.
bool Looper::IsPublic | ( | ) | const |
void Looper::SetPublic | ( | bool | bPublic | ) |
port_id Looper::GetMsgPort | ( | ) | const |
thread_id Looper::GetThread | ( | ) | const |
proc_id Looper::GetProcess | ( | ) | const |
status_t Looper::Lock | ( | ) |
status_t Looper::Lock | ( | bigtime_t | nTimeout | ) |
nTimeout
micro seconds before timing out and fail with errno==ETIME. nTimeout | Maximum number of micro seconds to wait for the looper mutex to be available. |
status_t Looper::SafeLock | ( | ) |
status_t Looper::Unlock | ( | ) |
void Looper::SetMutex | ( | Locker * | pcMutex | ) |
pcMutex | Pointer to the new mutex object or NULL to restore the default mutex |
Locker * Looper::GetMutex | ( | ) | const |
int Looper::GetLockCount | ( | ) | const |
thread_id Looper::GetLockingThread | ( | ) | const |
bool Looper::IsLocked | ( | ) | const |
thread_id Looper::Run | ( | void | ) | [virtual] |
Reimplemented in os::Application.
int Looper::Wait | ( | ) | const |
status_t Looper::PostMessage | ( | uint32 | nCode | ) |
nCode | The code that should be assigned to the sendt message |
status_t Looper::PostMessage | ( | Message * | pcMsg | ) |
pcMsg | The message to post. |
nCode | The code that should be assigned to the sendt message | |
pcHandler | Must point to a valid handler that will receive the message. | |
pcReplyTo | If not NULL should point to the handler that should receive the reply sendt to the message. |
status_t Looper::PostMessage | ( | Message * | pcMsg, | |
Handler * | pcHandler, | |||
Handler * | pcReplyHandler = NULL | |||
) |
nCode | The code that should be assigned to the sendt message | |
pcHandler | Must point to a valid handler that will receive the message. | |
pcReplyTo | If not NULL should point to the handler that should receive the reply sendt to the message. |
void Looper::SpoolMessages | ( | ) |
Message * Looper::GetCurrentMessage | ( | ) | const |
Message * Looper::DetachCurrentMessage | ( | ) |
Never do any lengthy operations in any hook members that are called from the looper thread if the looper is involved with the GUI (for example if the looper is a os::Window). The looper will not be able to dispatch messages until the hook returns so spending a long time in this member will make the GUI feel unresponsive.
pcMsg | - Pointer to the received messge. Note that this message will be deleted when DispatchMessage() returns, unless detatched from the looper through DetachCurrentMessage(). | |
pcHandler | - Pointer to the handler targeted by this message. If the message was not targeted at any spesific handler this argument is NULL. |
Reimplemented in os::Window.
void Looper::Started | ( | ) | [virtual] |
bool Looper::Idle | ( | ) | [virtual] |
Reimplemented in os_priv::DirKeeper.
MessageQueue * Looper::GetMessageQueue | ( | ) | const |
bool Looper::OkToQuit | ( | void | ) | [virtual] |
Reimplemented in HandlerSelector, os::ColorRequester, os::FileRequester, os::FontRequester, and os::InputBox.
void Looper::Quit | ( | ) | [virtual] |
void Looper::Terminate | ( | ) |
void Looper::AddTimer | ( | Handler * | pcTarget, | |
int | nID, | |||
bigtime_t | nPeriode, | |||
bool | bOneShot = true | |||
) |
pcTarget | Must be a valid ponter to a handler belonging to this looper. This is the handler that will get it's TimerTick() member called. | |
nID | An user defined ID that is passed to the TimerTick() function to make it possible to distinguish different timers. | |
nPeriode | Time in micro seconds before the timer fires. If not in one-shot mode, the timer will be rescheduled with the same delay until manually removed. | |
bOneShot | If true the timer will fire once, and then be removed. If false the timer will be continually rescheduled until removed by Looper::RemoveTimer(). |
bool Looper::RemoveTimer | ( | Handler * | pcTarget, | |
int | nID | |||
) |
- | pcTarget - The handler for which a timer is to be removed. | |
- | nID - The ID of the timer to be removed. |
const Looper::handler_map & Looper::GetHandlerMap | ( | ) | const |
void Looper::AddHandler | ( | Handler * | pcHandler | ) |
pcHandler | - Pointer to the handler to be added. |
bool Looper::RemoveHandler | ( | Handler * | pcHandler | ) |
pcHandler | The handler to remove |
pzName | The name to search for. |
int Looper::GetHandlerCount | ( | ) | const |
void Looper::SetDefaultHandler | ( | Handler * | pcHandler | ) |
pcHandler | The handler to set as default, or NULL |
Handler * Looper::GetDefaultHandler | ( | ) | const |
void Looper::AddCommonFilter | ( | MessageFilter * | pcFilter | ) |
void Looper::RemoveCommonFilter | ( | MessageFilter * | pcFilter | ) |
const MsgFilterList & Looper::GetCommonFilterList | ( | ) | const |
static Looper* os::Looper::GetLooperForThread | ( | thread_id | hThread | ) | [inline, static] |
bool Looper::FilterMessage | ( | Message * | pcMsg, | |
Handler ** | ppcTarget, | |||
std::list< MessageFilter * > * | pcFilterList | |||
) | [protected] |
friend class Application [friend] |
friend class Messenger [friend] |
Reimplemented from os::Handler.
friend class NodeMonitor [friend] |
Reimplemented from os::Handler.
friend class Window [friend] |