https://github.com/serso/thread-guard
Injects assertions in methods annotated with @MainThread or @WorkerThread
https://github.com/serso/thread-guard
Last synced: about 1 month ago
JSON representation
Injects assertions in methods annotated with @MainThread or @WorkerThread
- Host: GitHub
- URL: https://github.com/serso/thread-guard
- Owner: serso
- License: apache-2.0
- Created: 2018-10-22T19:36:17.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-01T12:48:12.000Z (over 7 years ago)
- Last Synced: 2025-01-07T17:43:36.695Z (over 1 year ago)
- Language: Java
- Size: 139 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Description
Protects against calling methods on wrong threads using AspectJ and Android's
`@MainThread`/`@WorkerThread` annotations.
# Usage
Set up AspectA as described here: https://github.com/serso/aspecta.
Import Thread Guard library to your project:
```groovy
dependencies {
implementation 'org.solovyev.android.threadguard:lib:1.0.2'
}
```
Optionally, you can specify how to penalize the violations:
```java
package org.example.android;
class App extends Application {
@Override
void onCreate() {
ThreadGuard.penaltyDeath();
// or
ThreadGuard.penaltyLog();
}
}
```