forked from kittinunf/fuel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare for next release/refactor a bit of code
- Loading branch information
Showing
6 changed files
with
49 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 0 additions & 46 deletions
46
fuel/src/main/java/com/github/kittinunf/fuel/util/SameThreadExecutorService.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
fuel/src/main/kotlin/com/github/kittinunf/fuel/util/SameThreadExecutorService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.github.kittinunf.fuel.util | ||
|
||
import java.util.concurrent.AbstractExecutorService | ||
import java.util.concurrent.TimeUnit | ||
|
||
/** | ||
* Executes all submitted tasks directly in the same thread as the caller. | ||
*/ | ||
class SameThreadExecutorService : AbstractExecutorService() { | ||
|
||
//volatile because can be viewed by other threads | ||
@Volatile private var terminated: Boolean = false | ||
|
||
override fun shutdown() { | ||
terminated = true | ||
} | ||
|
||
override fun isShutdown(): Boolean { | ||
return terminated | ||
} | ||
|
||
override fun isTerminated(): Boolean { | ||
return terminated | ||
} | ||
|
||
@Throws(InterruptedException::class) | ||
override fun awaitTermination(theTimeout: Long, theUnit: TimeUnit): Boolean { | ||
shutdown() | ||
return terminated | ||
} | ||
|
||
override fun shutdownNow(): List<Runnable> { | ||
return emptyList() | ||
} | ||
|
||
override fun execute(theCommand: Runnable) { | ||
theCommand.run() | ||
} | ||
} |