haiku/headers/os
Augustin Cavalier f66d2b46a8 kernel: Add event queue implementation to wait for objects efficiently.
Based on hamishm's original patch from 2015, but heavily modified,
refactored, and reworked.

From the original commit message:

> When an object is deleted, a B_EVENT_INVALID event is delivered,
> and the object is unregistered from the queue.
>
> The special event flag B_EVENT_ONE_SHOT can be passed in when adding
> an object so that the object is automatically unregistered when an
> event is delivered.

Modifications to the original change include:

 * Removed the public interface (syscalls remain private for the moment)

 * Event list queueing/dequeueing almost entirely rewritten, including:
  - Clear events field when dequeueing.

  - Have B_EVENT_QUEUED actually indicate whether the event has been
    appended to the linked list (or not), based around lock state.
    The previous logic was prone to races and double-insertions.

  - "Modify" is now just "Deselect + Select" performed at once;
    previously it could cause use-after-frees.

  - Unlock for deselect only once at the end of dequeue.

  - Handle INVALID events still in the queue upon destruction,
    fixing memory leaks.

 * Deduplified code with wait_for_objects.

 * Use of C++ virtual dispatch instead of C-style enum + function calls,
   and BReferenceable plus destructors for teardown.

 * Removed select/modify/delete flags. Select/Modify are now the same
   operation on the syscall interface, and "Delete" is done when 0
   is passed for "events". Additionally, the events selected can be fetched
   by passing -1 for "events".

 * Implemented level-triggered mode.

 * Use of BStackOrHeapArray and other convenience routines in syscalls.

Change-Id: I1d2f094fd981c95215a59adbc087523c7bbbe40b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6745
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2023-07-29 15:53:15 +00:00
..
add-ons Refactor touchpad movement generation by migrating MovementMaker to userland. 2022-07-18 16:00:29 +00:00
app headers/os: Make headers generator-friendly 2023-07-11 14:40:02 +00:00
arch kernel/arch/user_debugger: implement for risv64 2021-08-06 15:42:49 +00:00
be_apps be_apps/ServicesDaemon: Remove. 2016-07-29 18:41:30 -04:00
bluetooth bluetooth: ioctls always pass size on Haiku. 2018-11-18 14:42:09 -05:00
device USB: Move usb_iso_packet_descriptor to a separate header. 2021-09-02 16:00:17 +00:00
drivers USB: Support physical-vector bulk requests. 2023-05-30 17:54:28 +00:00
game More build fixes. 2020-01-25 21:35:34 +01:00
interface headers: Explicitly hide BAlert functions 2023-07-18 16:43:33 +00:00
kernel kernel: Add event queue implementation to wait for objects efficiently. 2023-07-29 15:53:15 +00:00
locale BCountry: add a GetPreferredLanguage method. 2021-07-21 07:20:39 +00:00
mail Migrate the BMailComponent docs to the Haiku Book. 2017-12-25 19:43:51 -05:00
media Enable some more Werror and fix compiler warnings 2022-04-22 14:25:48 +00:00
midi Fix clang warning "mismatched-tags" 2020-03-23 01:30:23 +00:00
midi2
net BNetworkDevice: Remove GetNextNetwork. 2023-03-29 20:15:32 -04:00
package package kit: Add pre-uninstall scripts feature. 2020-09-21 10:47:57 +00:00
storage Remove Spurious B_BEOS_DATA_DIRECTORY 2017-05-08 22:17:53 +02:00
support Merge remote-tracking branch 'origin/master' into dev/netservices 2022-09-04 07:30:59 +01:00
translation Tracker: Add thumbnail support 2021-08-27 11:39:13 +00:00
AppKit.h
Be.h
BeBuild.h headers/os: Bump max gcc to 13.x 2023-05-09 13:58:07 +00:00
DeviceKit.h
GameKit.h
InterfaceKit.h
KernelKit.h
LocaleKit.h Remove even more Locale Kit cruft. 2017-07-30 14:46:41 -04:00
MailKit.h
MediaKit.h Make BMediaRecorder public 2017-01-10 21:34:20 +01:00
MidiKit.h
NetKit.h
NetworkKit.h headers/NetworkKit: Drop now-private service calls from NetworkKit.h 2022-05-13 16:01:15 +00:00
StorageKit.h
SupportKit.h headers/os: Make headers generator-friendly 2023-07-11 14:40:02 +00:00
TranslationKit.h