Commit 723c6af9 authored by Julien Lepiller's avatar Julien Lepiller

utils: Add fibers utilities.

* torrent/utils/fibers.scm: New file.
* Makefile.am: Add it.
parent 0385af7a
include guile.am
SOURCES= \
torrent/utils/fibers.scm \
torrent/utils/fixnums.scm \
torrent/utils/sha-1.scm \
torrent/bencoding.scm \
......
;;;; Copyright (C) 2018 Julien Lepiller <julien@lepiller.eu>
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
;;;; License as published by the Free Software Foundation; either
;;;; version 3 of the License, or (at your option) any later version.
;;;;
;;;; This library is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;;;; Lesser General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU Lesser General Public
;;;; License along with this library; if not, write to the Free Software
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;;;;
(define-module (torrent utils fibers)
#:use-module (ice-9 match)
#:use-module (fibers)
#:use-module (fibers operations)
#:use-module (fibers timers)
#:export (timeout-perform-operation))
(define (timeout-perform-operation time op)
(catch
#t
(lambda ()
(match
(perform-operation
(choice-operation
(sleep-operation time)
op))
('timeout 'timeout)
(val val)))
(lambda _
'timeout)))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment