osquery-1/osquery
Giorgi Guliashvili ff1747347e
InterruptableRunnable RunnerInterruptPoint redesign (#4545)
* InterruptableRunnable RunnerInterruptPoint redesign

There were several inefficiencies in the old version of RunnerInterruptPoint and InterruptableRunnable.

1) RunnerInterruptPoint was throwing the exception when interrupted, however, the exception was always ignored.

2) InterruptableRunnable used the read-write lock, however only write lock was used.

3) InterruptableRunnable InterruptableRunnable, stored almost similar variable stop_, interrupted_.

4) std::atomic<bool> interrupted_ was used with locks, even though it was accessed by default safest access mode memory_order_seq_cst. So no additional cache invalidation was needed.

5) InterruptableRunnable contained code(in method interrupted() and variables bypass_check_, checked) just for testing. Which was slowing down method interrupted().

6) Some more confusing things. notify_all was not needed, as only one thread could be waiting for the conditional variable. RunnerInterruptPoint:: pause(void) looks ambiguous and that's why was not used anywhere.

I resolved all these problems by merging InterruptableRunnable and RunnerInterruptPoint into the InterruptableRunnable.

1) No use of the exception.
2) 4) Simple mutex, which is only used for pauseMilli. InterruptableRunnable::interrupted and InterruptableRunnable::interrupt function lock-free.
3) Single variable interrupted_.
5) Made InterruptableRunnable::interrupt virtual. Tests override interrupt to make things testable.
6) change to notify_one and removed pause without the specific time.
2018-06-15 16:15:43 +01:00
..
carver reorganized includes to improve compile time 2 (#4446) 2018-05-30 11:44:18 +01:00
config ATCPlugin fix ctor initialization order (#4540) 2018-06-13 17:17:28 +01:00
core Catch exceptions by ref on windows processes (#4541) 2018-06-13 21:06:38 +01:00
database Ephemeral native support for int (#4489) 2018-06-06 19:08:23 -07:00
devtools reorganized includes to improve compile time (#4445) 2018-05-30 00:17:40 +01:00
dispatcher InterruptableRunnable RunnerInterruptPoint redesign (#4545) 2018-06-15 16:15:43 +01:00
distributed reorganized includes to improve compile time (#4445) 2018-05-30 00:17:40 +01:00
events InterruptableRunnable RunnerInterruptPoint redesign (#4545) 2018-06-15 16:15:43 +01:00
examples Bundle C++ extensions into a single executable (#4335) 2018-06-03 02:04:36 +01:00
extensions Use just unique_ptr instead of shared in ImplExtensionClient (#4498) 2018-06-06 19:26:03 +01:00
filesystem Fix comment typos (#4542) 2018-06-13 14:51:27 +01:00
logger InterruptableRunnable RunnerInterruptPoint redesign (#4545) 2018-06-15 16:15:43 +01:00
main reorganized includes to improve compile time (#4445) 2018-05-30 00:17:40 +01:00
registry Registry: don't call external code holding lock (#4528) 2018-06-12 15:55:51 +01:00
remote Removed extra empty line at top of file (#4543) 2018-06-13 14:51:44 +01:00
sql SQL::selectFrom() pass columns as ref (#4544) 2018-06-13 14:32:10 +01:00
tables bug: correctly check windows event log channels for firing (#4550) 2018-06-13 21:40:50 +01:00
tests reorganized includes to improve compile time (#4445) 2018-05-30 00:17:40 +01:00
utils reorganized includes to improve compile time (#4445) 2018-05-30 00:17:40 +01:00
CMakeLists.txt llvm 6.0 and libFuzzer implementation (#4370) 2018-05-12 21:56:00 -04:00