History log of /haiku/headers/os/app/Looper.h
Revision Date Author Comments
# 151343eb 27-Nov-2018 Adrien Destugues <pulkomandy@pulkomandy.tk>

BLooper: API to hijack existing thread.

I need this to use loopers in WebKit, which spawns threads and expects
to be able to turn them into event loops later on.

This is the pattern already used in BApplication, we may as well make it
available elsewhere.

Change-Id: I5939ca89d33cb3bcc92567b302c2038d976af598
Reviewed-on: https://review.haiku-os.org/735
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 798ad3db 23-Apr-2015 Axel Dörfler <axeld@pinc-software.de>

BLooper: don't delete a launch_daemon port.

* Unless the service is really to be quit, the port should stay around;
but that decision is to be made by the launch_daemon, not the service
itself.


# 1480e5da 02-Apr-2015 Axel Dörfler <axeld@pinc-software.de>

The beginnings of a launch_daemon for Haiku.

* This will be heavily inspired by Apple's launchd, as well as
systemd -- for now it really doesn't do a whole lot, though.
* What works so far: the configuration files are read, parsed, and
the jobs created.
* The jobs are even initialized, and their message ports created.
* BApplication now retrieves a previously created port from the
launch_daemon for use with BServer.
* Only the registrar actually uses this for now.


# be902ac4 11-Jun-2014 John Scipione <jscipione@gmail.com>

App Kit: style changes.

No functional change intended.

Focused on documented classes only.

* Update copyright information.
* whitespace fixes.
* pointer style
* Rename some variables, msg => message, form => what
* Need consistent variable names to make documentation easier,
allows us to use \copydoc or \copydetails instead of repeating
ourselves over and over again.


# 5d7f782d 20-Dec-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BLooper: Add DispatchExternalMessage()

* This is primarily a service method for ports of widget tool kits
that require single-threaded GUI. DispatchExternalMessage() calls
DispatchMessage(), but also sets fLastMessage, so that
[Detach]CurrentMessage() work correctly. This allows to detach a
message in DispatchMessage() when called from the window thread,
add it to a global queue, and later process the queued messages in
a different thread that calls DispatchExternalMessage().
* BLooper/BWindow: Make sure fLastMessage is accessed only when locked.


# 18f5cd17 09-Sep-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Explicitly denote BPrivate to avoid clashes


# f20a8750 29-May-2008 Axel Dörfler <axeld@pinc-software.de>

* Enlarged the default BLooper port capacity to 200 messages. Since limiting
the message count doesn't really make much sense anyway (as opposed to
limiting the maximum size of waiting messages), we might still want to
enlarge this even more.
* This should further help with #2212.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25709 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eaad52e8 08-Aug-2007 Axel Dörfler <axeld@pinc-software.de>

Now uses the cache stack trick for a cheaper check_lock() version as suggested by stippi.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21863 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9dbe170a 26-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Implemented direct message passing for local targets; this fixes a deadlock
with PostMessage() in case the message queue is full.
Some notes:
* for synchronous replies, we don't use this mechanism yet, but it could be
extended to do that as well.
* the code looks so complicated because we need a way to access the looper's
queue without locking it (to prevent deadlocks); like Dano's solution, I've
abused BTokenSpace to store a BDirectMessageTarget with a BHandler.
* we also need to decouple the lifetime of a looper's queue from its target,
as we cannot lock the looper, and therefore, can't guarantee it stays valid
as long as we're accessing it outside of BLooper.
* init_clipboard() now needs to be done after the global constructors have
been called - since sending messages now needs gDefaultTokens to be initialized.
Since this is done per image, it shouldn't cause any troubles, though.
* some minor cleanup, removed unused _msg_cache_cleanup_() and friends.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19968 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c01f349e 25-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Cleanup:
* Got rid of unused BLooper members
* renamed fTaskID to fThread
* Removed private and deprecated AddLooper()/RemoveLooper()/... stuff; BLooper is now
directly calling BLooperList methods.
* Got rid of extensive and useless comments
* Made a few TODOs more clear
* Merged InitData() and InitData(...) to _InitData(...)
* BLooper::Team() now uses BPrivate::current_team(), sTeamID is gone now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19966 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a6c9722d 14-Jun-2006 Axel Dörfler <axeld@pinc-software.de>

Some cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17840 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 14d02d22 21-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

Huge cleanup and fixes:
* attachView() is now called _CreateSelf() and creates the app_server
view counterpart for itself, and no longer for a child view.
* removed superfluous deleteView().
* moved drawing from BWindow::DoUpdate() to BView::_Draw().
* made the recursive hook call functions consistent.
* fixed BWindow::DispatchMessage() to send public messages to the intended
target (instead of always handling them itself directly).
* DispatchMessage() no longer eats unmapped key events that were targeted
at the window directly.
* B_KEY_DOWN and B_KEY_UP events are now send to the target view as well
(this couldn't work before as BMessages were broken with B_PREFERRED_TOKEN).
* the default button is now correctly targeted by BWindow::_DetermineTarget()
(previously, the enter key was hacked to get through via _HandleKeyDown()).
* removing a view now also makes sure it won't have focus any longer.
* also, the DetachedFromWindow() hooks are now called first, so that any
changes made there cannot mess up our window anymore.
* removed BView::SetPattern(); _UpdatePattern() now does its job.
* renamend private methods to match our preferred style.
* removed unused methods and variables.
* more consistent naming overall.
* removed _PR3_COMPATIBLE_ stuff - there is definitely no need for us to be
compatible to that one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15060 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 752c4971 04-Aug-2002 ejakowatz <ejakowatz@nowhere.fake>

The last remnants of the Old Repub ... er, static looper list data has been
removed. The old static BLooper functions for managing the looper list are
still there, but they are officially deprecated. The approved interface
for this information is BPrivate::BLooperList, accessible via the global
BPrivate::gLooperList variable. Being as it lives in BPrivate, it is for
API-internal use *ONLY*. User apps use it to their own risk.
Also added a small test to make sure that the size of BLooper stays the
same. I will probably add this to other classes as well; doesn't hurt to
be safe. =)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@572 a95241bf-73f2-0310-859d-f6bbb57e9c96


# abb57933 15-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

Tweaks to deal with new repository hierarchy and use of unified CppUnit;
some bug fixes and a couple of new tests for BLooper.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@242 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52a38012 08-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

It is accomplished ...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 798ad3db303ec486d507f32915193f3456bfca86 23-Apr-2015 Axel Dörfler <axeld@pinc-software.de>

BLooper: don't delete a launch_daemon port.

* Unless the service is really to be quit, the port should stay around;
but that decision is to be made by the launch_daemon, not the service
itself.


# 1480e5da6fc4a2926c3da1a973e39927ac2171ae 02-Apr-2015 Axel Dörfler <axeld@pinc-software.de>

The beginnings of a launch_daemon for Haiku.

* This will be heavily inspired by Apple's launchd, as well as
systemd -- for now it really doesn't do a whole lot, though.
* What works so far: the configuration files are read, parsed, and
the jobs created.
* The jobs are even initialized, and their message ports created.
* BApplication now retrieves a previously created port from the
launch_daemon for use with BServer.
* Only the registrar actually uses this for now.


# be902ac4db5c9d0be72f6d54aa67b66e3dcc7eca 11-Jun-2014 John Scipione <jscipione@gmail.com>

App Kit: style changes.

No functional change intended.

Focused on documented classes only.

* Update copyright information.
* whitespace fixes.
* pointer style
* Rename some variables, msg => message, form => what
* Need consistent variable names to make documentation easier,
allows us to use \copydoc or \copydetails instead of repeating
ourselves over and over again.


# 5d7f782d4e505cb5788cdfb2abf7bdd174af084e 20-Dec-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BLooper: Add DispatchExternalMessage()

* This is primarily a service method for ports of widget tool kits
that require single-threaded GUI. DispatchExternalMessage() calls
DispatchMessage(), but also sets fLastMessage, so that
[Detach]CurrentMessage() work correctly. This allows to detach a
message in DispatchMessage() when called from the window thread,
add it to a global queue, and later process the queued messages in
a different thread that calls DispatchExternalMessage().
* BLooper/BWindow: Make sure fLastMessage is accessed only when locked.


# 18f5cd171bc62a0bf90c48f3a07a8f6e2f8b2297 09-Sep-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Explicitly denote BPrivate to avoid clashes


# f20a8750cb04148e4f8d79ba0fd0d905600997c8 29-May-2008 Axel Dörfler <axeld@pinc-software.de>

* Enlarged the default BLooper port capacity to 200 messages. Since limiting
the message count doesn't really make much sense anyway (as opposed to
limiting the maximum size of waiting messages), we might still want to
enlarge this even more.
* This should further help with #2212.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25709 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eaad52e8d72af216e4b306cd34323e30bb976130 08-Aug-2007 Axel Dörfler <axeld@pinc-software.de>

Now uses the cache stack trick for a cheaper check_lock() version as suggested by stippi.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21863 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9dbe170a694e59988263a752b746b6a82a5ff277 26-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Implemented direct message passing for local targets; this fixes a deadlock
with PostMessage() in case the message queue is full.
Some notes:
* for synchronous replies, we don't use this mechanism yet, but it could be
extended to do that as well.
* the code looks so complicated because we need a way to access the looper's
queue without locking it (to prevent deadlocks); like Dano's solution, I've
abused BTokenSpace to store a BDirectMessageTarget with a BHandler.
* we also need to decouple the lifetime of a looper's queue from its target,
as we cannot lock the looper, and therefore, can't guarantee it stays valid
as long as we're accessing it outside of BLooper.
* init_clipboard() now needs to be done after the global constructors have
been called - since sending messages now needs gDefaultTokens to be initialized.
Since this is done per image, it shouldn't cause any troubles, though.
* some minor cleanup, removed unused _msg_cache_cleanup_() and friends.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19968 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c01f349e6d41177d7be185b217eac237bcee621f 25-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Cleanup:
* Got rid of unused BLooper members
* renamed fTaskID to fThread
* Removed private and deprecated AddLooper()/RemoveLooper()/... stuff; BLooper is now
directly calling BLooperList methods.
* Got rid of extensive and useless comments
* Made a few TODOs more clear
* Merged InitData() and InitData(...) to _InitData(...)
* BLooper::Team() now uses BPrivate::current_team(), sTeamID is gone now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19966 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a6c9722d7365132f307e15cfb3504b216183df2f 14-Jun-2006 Axel Dörfler <axeld@pinc-software.de>

Some cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17840 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 14d02d22f66d08946519ad2b073be23fa78fc0c3 21-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

Huge cleanup and fixes:
* attachView() is now called _CreateSelf() and creates the app_server
view counterpart for itself, and no longer for a child view.
* removed superfluous deleteView().
* moved drawing from BWindow::DoUpdate() to BView::_Draw().
* made the recursive hook call functions consistent.
* fixed BWindow::DispatchMessage() to send public messages to the intended
target (instead of always handling them itself directly).
* DispatchMessage() no longer eats unmapped key events that were targeted
at the window directly.
* B_KEY_DOWN and B_KEY_UP events are now send to the target view as well
(this couldn't work before as BMessages were broken with B_PREFERRED_TOKEN).
* the default button is now correctly targeted by BWindow::_DetermineTarget()
(previously, the enter key was hacked to get through via _HandleKeyDown()).
* removing a view now also makes sure it won't have focus any longer.
* also, the DetachedFromWindow() hooks are now called first, so that any
changes made there cannot mess up our window anymore.
* removed BView::SetPattern(); _UpdatePattern() now does its job.
* renamend private methods to match our preferred style.
* removed unused methods and variables.
* more consistent naming overall.
* removed _PR3_COMPATIBLE_ stuff - there is definitely no need for us to be
compatible to that one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15060 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 752c497115c3496af9dad28de8c27276e3382a7a 04-Aug-2002 ejakowatz <ejakowatz@nowhere.fake>

The last remnants of the Old Repub ... er, static looper list data has been
removed. The old static BLooper functions for managing the looper list are
still there, but they are officially deprecated. The approved interface
for this information is BPrivate::BLooperList, accessible via the global
BPrivate::gLooperList variable. Being as it lives in BPrivate, it is for
API-internal use *ONLY*. User apps use it to their own risk.
Also added a small test to make sure that the size of BLooper stays the
same. I will probably add this to other classes as well; doesn't hurt to
be safe. =)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@572 a95241bf-73f2-0310-859d-f6bbb57e9c96


# abb579331f280333b113728756d2f79c03e3acbc 15-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

Tweaks to deal with new repository hierarchy and use of unified CppUnit;
some bug fixes and a couple of new tests for BLooper.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@242 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52a380120846174213ccce9c4aab0dda17c72083 08-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

It is accomplished ...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96