Commit graph

13 commits

Author SHA1 Message Date
Josh Gao
b43ad44f4c adb: fdevent: add fdevent_context_epoll.
Implement an epoll-backed fdevent_context, that reduces overhead when
we're polling many file descriptors. FdeventTest.smoke goes from ~5.2s
to ~3.3s when run on the host (after this patch's modification to change
it from chaining 10 file descriptors together to 512).

Test: adb_test on host
Test: adbd_test on blueline
Test: test_adb.py
Test: test_device.py
Change-Id: Iacf0093aa7bebea31e447c2cb012af72d8c3297e
2019-08-14 13:56:08 -07:00
Josh Gao
e22cb9f306 adb: extract soon-to-be-common code.
As a side effect, delete FDE_ACTIVE, which was always set on every
fdevent, and FDE_PENDING, which was an internal implementation detail.

This patch removes spin detection, which will be reimplemented
separately later.

Test: adb_test on host
Test: adbd_test on blueline
Change-Id: I40be3504ce03c4fae5e071fa018542a051b7511d
2019-08-14 13:56:08 -07:00
Anatol Pomazau
7b2ff6debc Add header that declares atomic primitives
It fixes a compilation issue:

/fdevent/fdevent_poll.cpp -o core/adb/fdevent/fdevent_poll.cpp.o
In file included from core/adb/fdevent/fdevent_poll.cpp:20:
In file included from core/adb/fdevent/fdevent_poll.h:29:
core/adb/fdevent/fdevent.h:106:10: error: no template named 'atomic' in namespace 'std'
    std::atomic<bool> terminate_loop_ = false;
    ~~~~~^

Change-Id: I5305a69a50e2638f514c5a7d47a9612b8ee38c69
2019-08-08 23:30:42 +00:00
Josh Gao
35b29360a2 adb: fdevent: extract Add/Del/SetTimeout.
Test: adb_test
Change-Id: Ibed301f8de73289837153fdfed370a681c24ac55
2019-07-08 18:32:24 -07:00
Josh Gao
33944a2742 adb: fdevent: extract Create/Destroy from fdevent_context_poll.
Test: adb_test
Change-Id: Ida308e8e281cbb2954277196a51945f124ce5823
2019-07-08 18:32:24 -07:00
Josh Gao
ebaa348d32 adb: fdevent: move TerminateLoop to fdevent_context.
Test: adb_test
Change-Id: Ib1f20aefdb36603e2ceac4197c02551f557056ee
2019-07-08 18:32:24 -07:00
Josh Gao
2c95bf73a5 adb: fdevent: move CheckMainThread logic to fdevent_context.
Test: adb_test
Change-Id: I10b93293af22d54ec739dc0f95c95df3ab082fb6
2019-07-08 18:32:24 -07:00
Josh Gao
e546f6816e adb: fdevent: delete FDE_CREATED.
All fdevents must be created by fdevent_create/fdevent_context::Create
now, so this flag is meaningless.

Test: none
Change-Id: I8489afad07bdb267ddfdb0dbb25d40d3a62f55f6
2019-07-08 18:05:55 -07:00
Josh Gao
95eef6b097 adb: fdevent: move run queue to fdevent_context.
Make the run queue logic reusable between implementations of fdevent by
moving it to the abstract base class.

Test: adb_test
Change-Id: If2f72e3ddc8007304bca63aa75446fa117267b25
2019-07-08 18:05:47 -07:00
Josh Gao
7adca93fe9 adb: implement fdevent_reset by constructing a new context.
Test: adb_test
Change-Id: Ie67afafe2b73fb2a8fc08568560adac6f456eb9a
2019-07-08 17:32:14 -07:00
Josh Gao
95068bbd9a adb: move fdevent implementation out to a separate file.
Test: mma
Change-Id: I8af945b9ae0accac75fa93c538e44cbab357bb5d
2019-07-08 16:03:27 -07:00
Josh Gao
c2cf121174 adb: de-globalize fdevent context.
Test: adb_test
Test: adbd_test
Change-Id: If711257d831b9090b38412821466c1d358d53d2d
2019-07-08 14:37:27 -07:00
Josh Gao
57e09b16ca adb: move fdevent to its own folder.
Preparatory refactoring for platform-specific implementations.

Test: mma
Change-Id: I0f600122ac89241788c5f3300f362fd9ef02ddcd
2019-07-08 14:37:27 -07:00