Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
9507a117
Unverified
Commit
9507a117
authored
Oct 08, 2025
by
Alexander Maryanovsky
Committed by
GitHub
Oct 08, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused Task class and its tests (#1112)
parent
ffbff629
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
223 deletions
+0
-223
Task.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/Task.kt
+0
-28
TaskTest.kt
skiko/src/jvmTest/kotlin/org/jetbrains/skiko/TaskTest.kt
+0
-195
No files found.
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/Task.kt
deleted
100644 → 0
View file @
ffbff629
package
org.jetbrains.skiko
import
kotlinx.coroutines.channels.Channel
import
java.util.concurrent.atomic.AtomicBoolean
internal
class
Task
{
private
val
onFinish
=
Channel
<
Unit
>(
1
)
private
var
done
=
AtomicBoolean
(
true
)
/**
* Run task and await its finishing (i.e. calling of [finish])
*/
suspend
fun
runAndAwait
(
run
:
suspend
()
->
Unit
)
{
done
.
set
(
false
)
run
()
onFinish
.
receive
()
}
/**
* Finish running task. If there is no running task, do nothing.
*/
fun
finish
()
{
if
(!
done
.
getAndSet
(
true
))
{
onFinish
.
trySend
(
Unit
)
}
}
}
\ No newline at end of file
skiko/src/jvmTest/kotlin/org/jetbrains/skiko/TaskTest.kt
deleted
100644 → 0
View file @
ffbff629
package
org.jetbrains.skiko
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.asCoroutineDispatcher
import
kotlinx.coroutines.isActive
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.runBlocking
import
kotlinx.coroutines.test.*
import
kotlinx.coroutines.yield
import
org.junit.Assert.assertFalse
import
org.junit.Assert.assertTrue
import
org.junit.Ignore
import
org.junit.Test
import
java.util.concurrent.Executors.newSingleThreadExecutor
import
java.util.concurrent.atomic.AtomicBoolean
import
kotlin.random.Random
internal
class
TaskTest
{
@Test
fun
`
runAndAwait
with
finish
`
()
=
runTest
{
val
task
=
Task
()
val
job
=
launch
{
task
.
runAndAwait
{}
}
testScheduler
.
advanceUntilIdle
()
task
.
finish
()
testScheduler
.
advanceUntilIdle
()
assertTrue
(
job
.
isCompleted
)
}
@Test
fun
`
runAndAwait
without
finish
`
()
=
runTest
{
val
task
=
Task
()
val
job
=
launch
{
task
.
runAndAwait
{}
}
testScheduler
.
advanceUntilIdle
()
assertFalse
(
job
.
isCompleted
)
job
.
cancel
()
}
@Test
fun
`
finish
inside
runAndAwait
`
()
=
runTest
{
val
task
=
Task
()
val
job
=
launch
{
task
.
runAndAwait
{
task
.
finish
()
}
}
testScheduler
.
advanceUntilIdle
()
assertTrue
(
job
.
isCompleted
)
}
@Test
fun
`
finish
before
runAndAwait
`
()
=
runTest
{
val
task
=
Task
()
val
job
=
launch
{
task
.
finish
()
task
.
runAndAwait
{}
}
testScheduler
.
advanceUntilIdle
()
assertFalse
(
job
.
isCompleted
)
job
.
cancel
()
}
@Test
(
timeout
=
5000
)
fun
`
finish
in
another
thread
`
()
{
val
task
=
Task
()
runBlocking
{
repeat
(
1000
)
{
task
.
runAndAwait
{
launch
(
Dispatchers
.
IO
)
{
task
.
finish
()
}
}
}
}
}
@Test
(
timeout
=
5000
)
fun
`
simulate
MacOs
layer
`
()
{
runBlocking
{
val
job
=
Job
()
val
layer
=
object
:
MacOsSimulatedLayer
(
scope
=
CoroutineScope
(
coroutineContext
+
job
))
{
val
draw
=
Task
()
override
fun
draw
()
{
draw
.
finish
()
}
suspend
fun
display
()
{
draw
.
runAndAwait
{
setNeedsDisplay
()
}
}
}
repeat
(
10000
)
{
layer
.
display
()
}
job
.
cancel
()
}
}
// TODO why do this test fail on CI? https://github.com/JetBrains/skiko/runs/5096776296?check_suite_focus=true
// (test timed out after 10000 milliseconds)
// What is wrong - Task class, this test, or UI tests somehow interfere with this test?
@Test
(
timeout
=
10000
)
@Ignore
fun
`
simulate
MacOs
layer
with
another
renderings
`
()
{
runBlocking
{
val
job
=
Job
()
val
layer
=
object
:
MacOsSimulatedLayer
(
scope
=
CoroutineScope
(
coroutineContext
+
job
))
{
val
draw
=
Task
()
override
fun
draw
()
{
draw
.
finish
()
}
suspend
fun
display
()
{
draw
.
runAndAwait
{
setNeedsDisplay
()
}
}
}
val
random
=
Random
(
42
)
val
anotherRenderingsJob1
=
launch
(
newSingleThreadExecutor
().
asCoroutineDispatcher
())
{
while
(
true
)
{
repeat
(
random
.
nextInt
(
4
))
{
layer
.
setNeedsDisplay
()
}
yield
()
}
}
val
anotherRenderingsJob2
=
launch
(
newSingleThreadExecutor
().
asCoroutineDispatcher
())
{
while
(
true
)
{
repeat
(
random
.
nextInt
(
4
))
{
layer
.
setNeedsDisplay
()
}
yield
()
}
}
repeat
(
10000
)
{
layer
.
display
()
}
job
.
cancel
()
anotherRenderingsJob1
.
cancel
()
anotherRenderingsJob2
.
cancel
()
}
}
private
abstract
class
MacOsSimulatedLayer
(
scope
:
CoroutineScope
)
{
private
val
dispatcher
=
newSingleThreadExecutor
().
asCoroutineDispatcher
()
private
var
needsDisplay
=
AtomicBoolean
(
false
)
init
{
scope
.
launch
(
dispatcher
)
{
while
(
isActive
)
{
if
(
needsDisplay
.
getAndSet
(
false
))
{
draw
()
}
yield
()
}
}
}
abstract
fun
draw
()
fun
setNeedsDisplay
()
{
needsDisplay
.
set
(
true
)
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment