xref: /haiku/docs/user/app/Looper.dox (revision f5821a1aee77d3b9a979b42c68a79e50b5ebaefe)
1/*
2 * Copyright 2008 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 * 		Niels Sascha Reedijk, niels.reedijk@gmail.com
7 *
8 * Corresponds to:
9 *		headers/os/app/Looper.h	rev 21863
10 *		src/kits/app/Looper.cpp	rev 21864
11 */
12
13/*!
14	\file Looper.h
15	\ingroup app
16	\ingroup libbe
17	\brief Provides the BLooper class.
18*/
19
20
21/*!
22	\def B_LOOPER_PORT_DEFAULT_CAPACITY
23	\brief The default size of the port of a BLooper.
24*/
25
26
27/*!
28	\class BLooper
29	\ingroup app
30	\ingroup libbe
31	\brief Receive and process messages in a separate thread.
32
33	When an object of this class is created, the message loop can be started
34	with Run(). This spawns the thread that receives messages and processes
35	messages. Messages are actually passed on to \link BHandler handlers \endlink
36	that are associated with this looper. By default there is always one
37	handler available: the looper itself. To 'quit' a looper, you should pass
38	a \c B_QUIT_REQUESTED message using one of the message post functions. When
39	a looper receives such a request, it will \b delete itself. As such, looper
40	should <em>always be created on the heap</em> (with \c new), and never on
41	the stack.
42
43	Posting messages can be done using the various PostMessage() methods.
44	Whenever a message is posted, it will be added through to the message
45	queue. It is possible to apply filters (see AddCommonFilter()) to filter
46	out any messages that correspond with certain criteria. The method will
47	copy the contents of the message and this copy is processed, so make sure
48	you delete the original messages in case you create them on the heap.
49	The handler for the message is chosen using the following criteria:
50
51	-# If PostMessage() or the BMessenger is set to a specific handler, and
52		this handler is associated with this looper, than the message is
53		processed by that handler.
54	-# Else, the preferred handler is used. You can set this using
55		SetPreferredHandler().
56	-# If there is no preferred handler, then the looper itself will process
57		the message.
58
59	Because a looper usually is used in multiple threads, you should make sure
60	you Lock() and Unlock() it during most operations. Locking calls can be
61	recursive (so multiple locks can come from a single thread), but make sure
62	you pair every Lock() with an Unlock() call. Failing to do so will
63	inevitably cause a deadlock.
64
65	Because a looper provides a separate thread, and the inherited handler is
66	usually a default handler, you will most often use this class by
67	subclassing it. For example, you are likely to subclass BWindow (which is
68	derived from BLooper) to customize your window and handle the messages
69	sent to that window. You can override Run() in case you want to perform
70	additional tasks before (or right after) starting the message loop. You can
71	override QuitRequested() if you want to decline quitting in certain
72	circumstances. You can override Quit() in case you want to perform
73	additional procedures during closing time. You can also override
74	DispatchMessage() if you want to do something with all incoming messages
75	before they are dispatched to a handler.
76
77	BLooper is one of the major base classes of the Haiku application
78	programmers interface. Closely related classes are BMessage, BHandler and
79	BMessenger. It is used in the interface kit, for example by the BWindow
80	class, which makes sure every window runs it its own thread.
81
82	BLooper is a part of the chain in the eloquent messaging structure. For a
83	proper understanding of all its facets, have a look at the \ref app_messaging
84	"messaging overview".
85*/
86
87
88/*!
89	\fn BLooper::BLooper(const char* name, int32 priority, int32 port_capacity)
90	\brief Construct a new BLooper with a \a priority and an \a capacity.
91
92	The new looper is, by default, not running yet. If you have set up
93	everything properly, you may call Run().
94
95	\attention Remember that loopers should be created on the heap, because
96		they will \c delete themselves in the Quit() method.
97
98	\param name The name of the looper.
99	\param priority The priority of the message thread of this looper. The
100		default priority should be good enough for most tasks. Also, some
101		derived versions of BLooper will use a specialized priority. So it is
102		advised to leave this setting at the default, unless you know why you
103		would like another setting.
104	\param port_capacity Loopers use ports to send and receive messages (see
105		the kernel kit). Ports have a maximum capacity; if there are so many
106		messages queued that the port is full, all other incoming messages are
107		dropped. There are situations where the size of the port should be
108		different from the default. This might be when your looper receives
109		a lot of messages, or if the message handling thread runs at a lower
110		priority than normal, which would decrease the processing speed.
111		Finding a suitable value for these custom scenarios would be done by
112		testing.
113
114	\see Run()
115*/
116
117
118/*!
119	\fn BLooper::~BLooper()
120	\brief Destruct the looper.
121
122	You will never delete a looper yourself. You should pass a
123	\c B_QUIT_REQUESTED message, or if you are destroying the looper from
124	inside its own message handling thread, you should call Quit().
125
126	\see Quit()
127*/
128
129
130///// Archiving /////
131
132
133/*!
134	\name Archiving
135*/
136
137
138//! @{
139
140
141/*!
142	\fn BLooper::BLooper(BMessage *data)
143	\brief Construct a looper from an archived message.
144
145	The \a data message has to be constructed by a BLooper::Archive() call.
146	Note that the data that is restored, is merely the port capacity and the
147	name of the looper/handler. Other data, such as filters, is not archived by
148	the default archiver.
149
150	\warning This constructor does no type check whatsoever. Since you can pass
151		any BMessage, you should - if you are not sure about the exact type -
152		use the Instantiate() method, which does check the type.
153
154	\see Instantiate()
155	\see Archive()
156*/
157
158
159/*!
160	\fn BArchivable *BLooper::Instantiate(BMessage *data)
161	\brief Static method to instantiate a looper from an archived message.
162
163	\return A pointer to the instantiated looper, or \c NULL if the \a data
164		is not a valid archived BLooper object.
165	\see BLooper(BMessage* data)
166*/
167
168
169/*!
170	\fn status_t BLooper::Archive(BMessage *data, bool deep) const
171	\brief Archive a looper to a message
172
173	Currently, only the name and the port capacity are archived. Any other
174	data, such as the filters, is not stored.
175
176	\param data The message to archive the object in.
177	\param deep This parameter is ignored, as BLooper does not have children.
178	\retval B_OK Archiving succeeded.
179	\retval B_BAD_VALUE The \a data parameter is not a valid message.
180	\see BLooper::Instantiate(BMessage *data)
181*/
182
183
184//! @}
185
186
187/*!
188	\name Message Mechanics
189*/
190
191
192//! @{
193
194
195/*!
196	\fn status_t BLooper::PostMessage(uint32 command)
197	\brief Post a message with the \a command as \c what identifier to this
198		looper.
199
200	Posting a message puts it in the message queue. The message passes through
201	the default handler chain.
202
203	\param command The \c what identifier of the message that needs to be sent.
204
205	\retval B_OK The operation succeeded, and the message is sent to the port.
206	\retval B_ERROR There was a general operation error.
207	\retval B_BAD_VALUE This looper is not yet running and therefore cannot
208		receive messages.
209
210	\see PostMessage(BMessage *) if you want to send a message with data
211		members.
212	\see PostMessage(uint32, BHandler *, BHandler *) if you want to send a
213		message to a specific handler, and request a reply.
214	\see PostMessage(BMessage *, BHandler *, BHandler *) for the same thing,
215		but with a complete message.
216*/
217
218
219/*!
220	\fn status_t BLooper::PostMessage(BMessage *message)
221	\brief Post a \a message to this looper.
222
223	Posting a message puts it in the message queue. The message passes through
224	the default handler chain.
225
226	The \a message is copied, and as such, you should make sure you will not
227	leak it. The best way to send messages is like this:
228
229\code
230	BMessage message;
231	message.what = B_DO_SOMETHING;
232	message.AddString("some_data", "This is data")
233
234	aLooper->PostMessage(&message);
235\endcode
236
237	\param message The message you would like to pass to this method.
238
239	\retval B_OK The operation succeeded, and the message is sent to the port.
240	\retval B_ERROR There was a general operation error.
241	\retval B_BAD_VALUE This looper is not yet running and therefore cannot
242		receive messages.
243
244	\see PostMessage(uint32) if you want to send a message without data
245		members.
246	\see PostMessage(uint32, BHandler *, BHandler *) if you want to send a
247		message to a specific handler, and request a reply.
248	\see PostMessage(BMessage *, BHandler *, BHandler *) for the same thing,
249		but with a complete message.
250*/
251
252
253/*!
254	\fn status_t BLooper::PostMessage(uint32 command, BHandler *handler,
255		BHandler *replyTo)
256	\brief Send a message with the \a command as \c what identifier to the
257		\a handler associated with this looper, and (optionally) request a
258		reply.
259
260	The target \a handler should be associated with this looper. This method
261	bypasses the default message queue.
262
263	\param command The value you want as the message's \c what identifier.
264	\param handler The handler you would like to pass this message to.
265	\param replyTo If you would like to request a reply, pass the handler to
266		which this reply should be directed to. If you pass \c NULL, you will
267		not receive a reply.
268
269	\retval B_OK The operation succeeded, and the message is sent to the port.
270	\retval B_ERROR There was a general operation error.
271	\retval B_BAD_VALUE This looper is not yet running and therefore cannot
272		receive messages.
273	\retval B_MISMATCHED_VALUES The \a handler is not associated with this
274		looper.
275
276	\see PostMessage(uint32) if you want to send a message without data
277		members.
278	\see PostMessage(BMessage *) if you want to send a message with data
279		members.
280	\see PostMessage(BMessage *, BHandler *, BHandler *) if you want to send a
281		message to a specific handler, and request a reply.
282*/
283
284
285/*!
286	\fn status_t BLooper::PostMessage(BMessage *message, BHandler *handler,
287		BHandler *replyTo)
288	\brief Send a \a message to the \a handler associated with this looper,
289		and (optionally) request a reply.
290
291	The target \a handler should be associated with this looper. This method
292	bypasses the default message queue.
293
294	The \a message is copied, and as such, you should make sure you will not
295	leak it. The best way to send messages is like this:
296
297\code
298	BMessage message;
299	message.what = B_DO_SOMETHING;
300	message.AddString("some_data", "This is data")
301
302	aLooper->PostMessage(&message, aHandler);
303\endcode
304
305	\param message The message you want to pass.
306	\param handler The handler you would like to pass this message to.
307	\param replyTo If you would like to request a reply, pass the handler to
308		which this reply should be directed to. If you pass \c NULL, you will
309		not receive a reply.
310
311	\retval B_OK The operation succeeded, and the message is sent to the port.
312	\retval B_ERROR There was a general operation error.
313	\retval B_BAD_VALUE This looper is not yet running and therefore cannot
314		receive messages.
315	\retval B_MISMATCHED_VALUES The \a handler is not associated with this
316		looper.
317
318	\see PostMessage(uint32) if you want to send a message without data
319		members.
320	\see PostMessage(BMessage *) if you want to send a message with data
321		members.
322	\see PostMessage(uint32, BHandler *, BHandler *) if you want to send a
323		message without data to a specific handler, and request a reply.
324*/
325
326
327//! @}
328
329
330/*!
331	\name Message Processing
332*/
333
334
335//! @{
336
337
338/*!
339	\fn void BLooper::DispatchMessage(BMessage *message, BHandler *handler)
340	\brief Dispatch a message to a handler. Override if there are messages that
341		you want to catch before they are sent to the handlers.
342
343	This method is called by the message looping thread to dispatch a message
344	to \a handler. If you implement the BLooper class and your looper receives
345	messages that absolutely have to be processed by the looper instead of any
346	of the handlers, override this method. For example, the default
347	implementation catches B_QUIT_REQUESTED messages before they are sent to
348	the handlers, so that the looper will quit at those messages.
349
350	You are discouraged from using this method to filter out any messages you
351	do not want to process. For this, there is a more generic method using
352	the BMessageFilter class. If you want to skip messages with certain
353	patterns, have a look at the AddCommonFilter() and SetCommonFilterList()
354	methods.
355
356	If you do override this method, please remember to call the
357	DispatchMessage() method of the parent class.
358*/
359
360
361/*!
362	\fn void BLooper::MessageReceived(BMessage *msg)
363	\brief Process a message received by the internal handler of this looper.
364
365	Reimplemented from BHandler::MessageReceived();
366*/
367
368
369/*!
370	\fn BMessage* BLooper::CurrentMessage() const
371	\brief Retrieve the current message.
372
373	\attention Only call this method from within the thread that processes the
374		messages. It contains a pointer to the message that is currently being
375		handled. Due to the multithreaded nature of the operating system, this
376		method will not safely let you read the message that is being processed
377		by this handler from outside the context of the processing. If you do
378		want to use a message outside of the processing thread, have a look at
379		DetachCurrentMessage() to safely retrieve a message.
380
381	\return A pointer to the message that is currently being processed. Note
382		that calling it from outside the thread that processes the message,
383		could give you a \c NULL pointer or an invalid pointer.
384*/
385
386
387/*!
388	\fn BMessage* BLooper::DetachCurrentMessage()
389	\brief Get ownership of the message currently being processed.
390
391	Retrieve the current message and gain ownership of it. This means that the
392	message will not be deleted as soon as the looper is done processing it.
393	You can then use it for different purposes.
394
395	\attention Only call this method from within the thread that processes the
396	messages. Due to the multithreaded nature of the operating system, calling
397	it from another thread is very likely to give you an invalid or a \c NULL
398	pointer.
399*/
400
401
402/*!
403	\fn BMessageQueue* BLooper::MessageQueue() const
404	\brief Get a pointer to the internal message queue of this looper.
405
406	You can use this pointer to manipulate the message queue. Note that the
407	message that is being processed is already detached from this queue.
408
409	\return A pointer to the internal message queue.
410*/
411
412
413/*!
414	\fn bool BLooper::IsMessageWaiting() const
415	\brief Check if there is a message waiting.
416
417	\retval true There are still messages to be processed.
418	\retval false There is no message waiting.
419*/
420
421
422//! @}
423
424
425/*!
426	\name Handler Management
427*/
428
429
430//! @{
431
432
433/*!
434	\fn void BLooper::AddHandler(BHandler* handler)
435	\brief Associate a \a handler to this looper.
436
437	The \a handler will be associated to this looper. By default, the handler
438	in this looper will be chained to the supplied \a handler.
439
440	\param handler The handler to associate with this looper. If the handler is
441		already associated to another looper, the operation will fail silently.
442		Check beforehand if you cannot be sure that the \a handler is
443		unassociated.
444
445	\see RemoveHandler()
446*/
447
448
449/*!
450	\fn bool BLooper::RemoveHandler(BHandler* handler)
451	\brief Disassociate a \a handler from this looper.
452
453	If the handler is disassociated, it can be reassociated to another looper.
454
455	\retval true The \a handler has been removed from this looper.
456	\retval false The \a handler was invalid. or the handler was not
457		associated to this looper.
458	\see AddHandler()
459*/
460
461
462/*!
463	\fn int32 BLooper::CountHandlers() const
464	\brief Get the number of handlers associated with this looper.
465
466	\see HandlerAt(), IndexOf()
467*/
468
469
470/*!
471	\fn BHandler* BLooper::HandlerAt(int32 index) const
472	\brief Get the handler at an \a index of the list of associated handlers.
473
474	\return A pointer to the handler at that \a index, or \c NULL if the
475		\a index is out of range.
476
477	\see CountHandlers(), IndexOf()
478*/
479
480
481/*!
482	\fn int32 BLooper::IndexOf(BHandler* handler) const
483	\brief Get the index of the \a handler that is in the associated handler
484		list.
485
486	\return If the \a handler is not in the list, this method will return -1.
487		Else, you will get the index of the handler in the list.
488*/
489
490
491/*!
492	\fn BHandler* BLooper::PreferredHandler() const
493	\brief Get the preferred handler.
494
495	\return A pointer to the preferred handler, or \c NULL if none is set.
496	\see SetPreferredHandler()
497*/
498
499
500/*!
501	\fn void BLooper::SetPreferredHandler(BHandler* handler)
502	\brief Set a preferred handler.
503
504	If messages are posted to this looper using one of the PostMessage()
505	methods without a specific BHandler argument, the messages will be handled
506	by the looper itself (since a looper is a subclass of BHandler, this is
507	perfectly possible). If you want to override that behavior, you should set
508	a preferred handler. This handler will be called if incoming messages do
509	not ask to be directly passed on to a specific handler.
510
511	\param handler The preferred handler you want undesignated messages to be
512		handled by. If you want to unset the preferred handler, pass \c NULL.
513		If the supplied \a handler is not associated with this looper, this
514		call will fail silently and the current preferred handler will be unset.
515	\see PreferredHandler()
516*/
517
518
519//! @}
520
521
522/*!
523	\name Loop Control
524*/
525
526
527//! @{
528
529
530/*!
531	\fn thread_id BLooper::Run()
532	\brief Start the event loop.
533
534	After the looper has been constructed, it needs to be started using this
535	method. A thread will be spawned, which will receive messages.
536
537	Make sure the looper is not yet running before you call this method.
538
539	\return A (positive) thread id if spawning the thread succeeded, or an
540		error code.
541*/
542
543
544/*!
545	\fn void BLooper::Quit()
546	\brief Hook method that is called after a \c B_QUIT_REQUESTED message.
547
548	If you want to quit and delete the looper, you should post a
549	\c B_QUIT_REQUESTED message. This will first call the hook method
550	QuitRequested(), which can be overridden in child classes in case there
551	are conditions that would prevent the looper to be quit. If you really
552	know what you are doing, and you definitely want to quit this looper,
553	you may call this method, but only after performing a Lock() operation.
554
555	Override this method if your subclass needs to perform specific clean-up
556	tasks. Remember to call the base class implementation when you're done.
557
558	\attention You will not have to delete the looper object, if a looper quits
559		it will delete itself.
560*/
561
562
563/*!
564	\fn bool BLooper::QuitRequested()
565	\brief Hook method that is called during a \c B_QUIT_REQUESTED message.
566
567	This hook function is called by the looper thread when a
568	\c B_QUIT_REQUESTED is received. The default implementation always accepts
569	the message, but if your subclass needs a special condition to be met
570	before actually accepting a quit message, you can test for that condition
571	in this hook method. A good example is a window (which is a derivative of
572	BLooper), which contains a modified document. The condition may be that a
573	modal dialog requesting a path of action is closed.
574
575	\retval true The looper can be quit and destroyed.
576	\retval false Do not accept the quit message and continue processing
577		messages.
578*/
579
580
581/*!
582	\fn bool BLooper::Lock()
583	\brief Lock the looper.
584
585	For most operations involving the internal data of the looper, you need to
586	hold the lock. Each looper implements a global lock, which you can use to
587	perform operations on internal data in a thread-safe manner.
588
589	Do not forget to pair each Lock() request with an Unlock() request. Lock()
590	requests can be stacked, which means that recursively locking a looper from
591	a thread that actually holds the lock, will not cause a deadlock. See
592	BLocker for more information on locking internals.
593
594	\retval true The locking request succeeded.
595	\retval false The locking request could not be completed. There are a
596		variety of reasons for this to happen, for example when the looper is
597		destroyed.
598	\see Unlock(), LockWithTimeout(), IsLocked()
599*/
600
601
602/*!
603	\fn void BLooper::Unlock()
604	\brief Unlock a locked looper.
605
606	Use this method paired with Lock() calls, to release a lock. Make sure that
607	this method is only called on a locked looper.
608
609	\see Lock(), LockWithTimeout(), IsLocked()
610*/
611
612
613/*!
614	\fn bool BLooper::IsLocked() const
615	\brief Check if a looper is locked.
616
617	\retval true The looper is locked.
618	\retval false The looper is not locked, or the looper has been deleted.
619	\see Lock(), Unlock(), LockWithTimeout()
620*/
621
622
623/*!
624	\fn status_t BLooper::LockWithTimeout(bigtime_t timeout)
625	\brief Lock a looper with a \a timeout.
626
627	This method locks the looper like Lock(), but if the locking request does
628	not succeed within the provided \a timeout, the method will return.
629
630	\param timeout The maximum time to wait for the lock request to succeed.
631
632	\retval B_OK The lock is acquired.
633	\retval B_BAD_VALUE The looper has been destroyed.
634	\retval "other errors" There was an error acquiring the lock.
635	\see Lock(), Unlock(), IsLocked()
636*/
637
638
639/*!
640	\fn thread_id BLooper::Thread() const
641	\brief Return the thread id of the internal message looper thread.
642
643	If the looper is not yet running, this method will return 0.
644
645	\see Run()
646*/
647
648
649/*!
650	\fn team_id BLooper::Team() const
651	\brief Return the team id in which this looper exists.
652*/
653
654
655/*!
656	\fn BLooper* BLooper::LooperForThread(thread_id thread)
657	\brief Static method to retrieve a BLooper for a specified \a thread.
658*/
659
660
661//! @}
662
663
664/*!
665	\name Loop debugging
666
667	These methods may aid you in debugging problems when they occur, but do not
668	use these in actual production code. These methods are unrealiable because
669	they are not thread-safe, and as such are only useful in specific debugging
670	situations. Handle with care.
671*/
672
673
674//! @{
675
676
677/*!
678	\fn thread_id BLooper::LockingThread() const
679	\brief Return the thread id of the thread that currenty holds the lock.
680*/
681
682
683/*!
684	\fn int32 BLooper::CountLocks() const
685	\brief Return the number of recursive locks that are currently being held
686	on this looper
687*/
688
689
690/*!
691	\fn int32 BLooper::CountLockRequests() const
692	\brief Return the number of pending locks.
693*/
694
695
696/*!
697	\fn sem_id BLooper::Sem() const
698	\brief Return the id of the semaphore that is used to lock this looper.
699*/
700
701
702//! @}
703
704
705/*!
706	\name Scripting Functions
707*/
708
709
710//! @{
711
712
713/*!
714	\fn BHandler* BLooper::ResolveSpecifier(BMessage* msg, int32 index,
715		BMessage* specifier, int32 form, const char* property)
716	\brief Determine the proper handler for a scripting message.
717
718	\see BHandler::ResolveSpecifier()
719*/
720
721
722/*!
723	\fn status_t BLooper::GetSupportedSuites(BMessage* data)
724	\brief Reports the suites of messages and specifiers that derived classes
725		understand.
726
727	\param data The message to report the suite of messages and specifiers.
728
729	\see BHandler::GetSupportedSuites()
730*/
731
732
733//! @}
734
735
736/*!
737	\name Looper Message Filters
738	Note that filters added with these methods will be applied to all
739	associated handlers. Have a look at the filtering methods of the BHandler
740	class to see how filters can be applied to the inherited handler of this
741	looper specifically.
742*/
743
744
745//! @{
746
747
748/*!
749	\fn void BLooper::AddCommonFilter(BMessageFilter* filter)
750	\brief Add a common filter to the list of filters that are applied to all
751		incoming messages.
752
753	Filters can only be applied once, so they cannot be shared between loopers,
754	a handler and a looper or between two handlers.
755
756	The \a filter is not copied; rather a pointer is stored. Keep the \a filter
757	alive as long as it is used by a looper.
758
759	\see RemoveCommonFilter(), SetCommonFilterList(), CommonFilterList()
760*/
761
762
763/*!
764	\fn bool BLooper::RemoveCommonFilter(BMessageFilter* filter)
765	\brief Remove a \a filter from the common message filter list.
766
767	Note that this will not free the memory used by the \a filter, so you
768	should dispose of it yourself.
769
770	\see AddCommonFilter(), SetCommonFilterList(), CommonFilterList()
771*/
772
773
774/*!
775	\fn void BLooper::SetCommonFilterList(BList* filters)
776	\brief Set a new list of \a filters that need to be applied to all
777		incoming messages.
778
779	You are responsible for validating that all the items in the list of
780	\a filters are actual filters. The old list is discarded; all the filters
781	are \b destroyed.
782
783	Note that filters can only be applied to one looper or handler. If any
784	of the filters is already associated with another one, this call will fail.
785
786	\see AddCommonFilter(), RemoveCommonFilter(), CommonFilterList()
787*/
788
789
790/*!
791	\fn BList* BLooper::CommonFilterList() const
792	\brief Return a list of filters applied to all incoming messages.
793
794	\return A pointer to the internal filter list, or \c NULL if such a list
795		has not yet been created. Please note that you should use the internal
796		list management functions to manipulate the internal filter list, in
797		order to maintain internal consistency.
798	\see AddCommonFilter(), RemoveCommonFilter(), SetCommonFilterList()
799*/
800
801//! @}
802
803
804/*!
805	\fn status_t BLooper::Perform(perform_code d, void* arg)
806	\brief Internal method.
807*/
808
809
810/*!
811	\fn BMessage* BLooper::MessageFromPort(bigtime_t timeout)
812	\brief Hook method to retrieve a message from the looper's port.
813
814	The default implementation is called by the internal message looping thread
815	and retrieves the next message from the port that belongs to this looper.
816
817	If you use a looper in a context where it might receive messages from other
818	sources, you can override this method in order to insert these methods into
819	the message processing. Note that any messages that are returned by this
820	method will be deleted by this looper, so make sure you have ownership of
821	the message. If you override this method, remember to call the base
822	implementation every now and then, in order to retrieve the messages
823	arriving at the default port.
824*/
825
826