Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
c590b339
Commit
c590b339
authored
9 years ago
by
Manos Koukoutos
Browse files
Options
Downloads
Patches
Plain Diff
Fix ugliness in InterruptManager
parent
284bdf34
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/leon/utils/InterruptManager.scala
+9
-13
9 additions, 13 deletions
src/main/scala/leon/utils/InterruptManager.scala
with
9 additions
and
13 deletions
src/main/scala/leon/utils/InterruptManager.scala
+
9
−
13
View file @
c590b339
...
@@ -5,36 +5,32 @@ package utils
...
@@ -5,36 +5,32 @@ package utils
import
scala.collection.JavaConversions._
import
scala.collection.JavaConversions._
import
java.util.concurrent.atomic.AtomicBoolean
import
java.util.concurrent.atomic.
{
AtomicLong
,
AtomicBoolean
}
import
sun.misc.
{
Signal
,
SignalHandler
}
import
sun.misc.
{
Signal
,
SignalHandler
}
import
java.util.WeakHashMap
import
java.util.WeakHashMap
class
InterruptManager
(
reporter
:
Reporter
)
extends
Interruptible
{
class
InterruptManager
(
reporter
:
Reporter
)
extends
Interruptible
{
private
[
this
]
val
interruptibles
=
new
WeakHashMap
[
Interruptible
,
Boolean
]()
private
[
this
]
val
interruptibles
=
new
WeakHashMap
[
Interruptible
,
Boolean
]()
private
[
this
]
val
sigINT
=
new
Signal
(
"INT"
)
private
[
this
]
val
sigINT
=
new
Signal
(
"INT"
)
private
[
this
]
val
withinTimeout
:
AtomicBoolean
=
new
AtomicBoolean
(
false
)
private
[
this
]
val
lastTimestamp
=
new
AtomicLong
(
0L
)
private
val
exitWindow
=
1000L
private
[
this
]
val
handler
=
new
SignalHandler
{
private
[
this
]
val
handler
=
new
SignalHandler
{
def
handle
(
sig
:
Signal
)
{
def
handle
(
sig
:
Signal
)
{
println
()
def
now
()
:
Long
=
System
.
currentTimeMillis
()
if
(
withinTimeout
.
get
())
{
reporter
.
info
(
""
)
if
(
now
()
-
lastTimestamp
.
get
<
exitWindow
)
{
reporter
.
warning
(
"Aborting Leon..."
)
reporter
.
warning
(
"Aborting Leon..."
)
System
.
exit
(
1
)
System
.
exit
(
1
)
}
}
else
{
else
{
reporter
.
warning
(
"Interrupted..."
)
reporter
.
warning
(
"Interrupted..."
)
s
e
tTime
out
(
)
la
stTime
stamp
.
set
(
now
()
)
interrupt
()
interrupt
()
}
}
}
}
}
}
private
val
exitWindow
=
1000
private
[
this
]
def
setTimeout
()
=
{
import
scala.concurrent.Future
import
scala.concurrent.ExecutionContext.Implicits.global
withinTimeout
.
set
(
true
)
Future
{
Thread
.
sleep
(
exitWindow
)
}
onComplete
{
_
=>
withinTimeout
.
set
(
false
)
}
()
}
val
interrupted
:
AtomicBoolean
=
new
AtomicBoolean
(
false
)
val
interrupted
:
AtomicBoolean
=
new
AtomicBoolean
(
false
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment