Commit Graph

18 Commits

Author SHA1 Message Date
Konstantin Käfer
9b961fb6f9 [core] factor out RunLoop::wake() 2018-02-07 18:21:58 +01:00
Chris Loer
5da5ba7706 [core, ios, qt, android] Close race condition in RunLoop (issue #9620)
Because a message we queue from the foreground may cause the background to complete, exit, and tear down the AsyncTask, we have to block queue processing until we've finished our call to AsyncTask::send().
Broadening the scope of a mutex is scary, but I audited the code of our four implementations of AsyncTask and I don't see any way this could cause a deadlock.
2017-11-27 14:42:44 -08:00
Ivo van Dongen
f4f4d13b70 [all] ensure runloop is the current scheduler 2017-08-09 12:08:21 +03:00
Thiago Marcos P. Santos
7e8bdadb91 [core] Rename ThreadedObject to Thread
Now that the old Thread class is gone, we can give ThreadedObject
a better name.
2017-06-21 14:30:09 +03:00
Thiago Marcos P. Santos
c247a4b10c [android] Replace util::Thread with util::ThreadedObject 2017-06-21 14:30:09 +03:00
Konstantin Käfer
f436913550 [android] Remove public usage of private util/thread.hpp header 2017-03-28 13:53:19 +02:00
Konstantin Käfer
e76de05402 [build] move logging to util 2016-11-22 20:58:51 +01:00
Thiago Marcos P. Santos
d52faadf73 [android] Set thread name properly 2016-07-16 10:38:42 +03:00
Thiago Marcos P. Santos
480e26c53f [android] Add support for timers on the main thread
Wake up the main thread run loop with a file descriptor event from a
thread that exists for this sole purpose.
2016-07-06 17:43:19 +03:00
Thiago Marcos P. Santos
2425cf4ef8 Revert "[android] Do not create Timers on Default main loops"
This reverts commit 13cd75f099.
2016-07-06 17:43:09 +03:00
Thiago Marcos P. Santos
dfd0b105cd [android] Fix issue when stop is called before run on the RunLoop
The current ::stop() implementation was not thread safe and we
should queue the ::stop() for the next loop iteration so even
if we call ::stop() before ::run(), it gets processed.
2016-07-05 21:04:27 +03:00
Thiago Marcos P. Santos
13cd75f099 [android] Do not create Timers on Default main loops
Not supported, because we don't have control over the Looper
timeout like we do for Loopers we create. On the main thread,
Android takes care of making the application sleep and sets
an arbitrary timeout. This could be properly fixed by implementing
timers in Java, but we don't really have the use case of timers
in the main thread.
2016-07-05 21:04:27 +03:00
Thiago Marcos P. Santos
e579199ac1 [android] Fix a bug when canceling tasks
If the next task in the queue gets canceled, we need to
adjust the iterator to the next task, otherwise a canceled
task gets executed.
2016-07-05 21:04:27 +03:00
Thiago Marcos P. Santos
70d4ebb347 [android] Fix default RunLoop not stopping
stop() for default RunLoop is only used by unit tests and we need
to wake the ALooper to get past run().
2016-07-05 21:04:27 +03:00
John Firebaugh
6e78eabfff [core] Clean up ThreadContext vestiges 2016-04-15 09:56:18 -07:00
Thiago Marcos P. Santos
40e590b681 [android] Use ALooper_addFd() and callbacks to wake up
This is needed for plugging into an existing Looper because
we won't call ::run() on the main thread (this is called
on the Java side of the application automatically by Android).

But we still need to wake up and process the events. For that
we create a pipe and write to the pipe to wake up the main
loop and we process events on the callback of the fd handler.

Fixes #4682
2016-04-14 13:44:08 -07:00
Thiago Marcos P. Santos
10b503eabf [android] Attach thread on the RunLoop
Needed because Looper could be used by Java and it would crash
complaining that we didn't detach otherwise.
2016-04-06 04:52:51 -03:00
Thiago Marcos P. Santos
74a1d3c164 [android] Introduce RunLoop based on Looper
Also implement a Timer and AsyncTask based on Android's Looper.
2016-04-06 04:52:51 -03:00