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