Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cmucl
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Shapiro
cmucl
Commits
dc46cb5b
Commit
dc46cb5b
authored
26 years ago
by
dtc
Browse files
Options
Downloads
Patches
Plain Diff
Add the with-timeout macro.
parent
2b72dfd5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
code/exports.lisp
+2
-2
2 additions, 2 deletions
code/exports.lisp
code/multi-proc.lisp
+31
-2
31 additions, 2 deletions
code/multi-proc.lisp
with
33 additions
and
4 deletions
code/exports.lisp
+
2
−
2
View file @
dc46cb5b
...
...
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(
ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/exports.lisp,v 1.1
59
199
8/12
/1
9
1
5:52:06
dtc Exp $"
)
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/exports.lisp,v 1.1
60
199
9
/01
/1
1
1
9:05:35
dtc Exp $"
)
;;;
;;; **********************************************************************
;;;
...
...
@@ -1704,4 +1704,4 @@
"PROCESS-WAIT"
"PROCESS-WAIT-WITH-TIMEOUT"
"PROCESS-WHOSTATE"
"PROCESS-YIELD"
"PROCESSP"
"RESTART-PROCESS"
"SHOW-PROCESSES"
"STACK-GROUP-RESUME"
"WITHOUT-SCHEDULING"
"WITH-LOCK-HELD"
))
"WITH-LOCK-HELD"
"WITH-TIMEOUT"
))
This diff is collapsed.
Click to expand it.
code/multi-proc.lisp
+
31
−
2
View file @
dc46cb5b
...
...
@@ -5,7 +5,7 @@
;;; the Public domain, and is provided 'as is'.
;;;
(
ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/multi-proc.lisp,v 1.3
1
199
8
/0
9/26 18:24:42 pw
Exp $"
)
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/multi-proc.lisp,v 1.3
2
199
9
/0
1/11 19:05:36 dtc
Exp $"
)
;;;
;;; **********************************************************************
;;;
...
...
@@ -1527,6 +1527,35 @@
(
process-wait-with-timeout
"Sleep"
n
(
constantly
nil
)))))
;;; With-Timeout-Internal -- Internal
;;;
(
defun
with-timeout-internal
(
timeout
function
timeout-function
)
(
catch
'timer-interrupt
(
let*
((
current-process
mp:*current-process*
)
(
timer-process
(
mp:make-process
#'
(
lambda
()
(
sleep
timeout
)
(
mp:process-interrupt
current-process
#'
(
lambda
()
(
throw
'timer-interrupt
nil
))))
:name
"Timeout timer"
)))
(
unwind-protect
(
return-from
with-timeout-internal
(
funcall
function
))
(
mp:destroy-process
timer-process
))))
(
funcall
timeout-function
))
;;; With-Timeout -- Public
;;;
(
defmacro
with-timeout
((
timeout
&body
timeout-forms
)
&body
body
)
"Executes body and returns the values of the last form in body. However, if
the execution takes longer than timeout seconds, abort it and evaluate
timeout-forms, returning the values of last form."
`
(
flet
((
fn
()
.
,
body
)
(
tf
()
.
,
timeout-forms
))
(
with-timeout-internal
,
timeout
#'
fn
#'
tf
)))
;;; Show-Processes -- Public
;;;
(
defun
show-processes
(
&optional
verbose
)
...
...
@@ -1536,7 +1565,7 @@
(
fresh-line
)
(
dolist
(
process
*all-processes*
)
(
when
(
eq
process
*current-process*
)
(
format
t
"
*
"
))
(
format
t
"
->
"
))
(
format
t
"~s ~s ~a~%"
process
(
process-whostate
process
)
(
process-state
process
))
(
when
verbose
...
...
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