parent
2c5413cec5
commit
69bd188cc0
|
@ -8,8 +8,6 @@
|
||||||
- balance needs USE:
|
- balance needs USE:
|
||||||
- command line arguments
|
- command line arguments
|
||||||
- socket protocol
|
- socket protocol
|
||||||
- irc: stack underflow?
|
|
||||||
- ignore SIGPIPE
|
|
||||||
|
|
||||||
+ docs:
|
+ docs:
|
||||||
|
|
||||||
|
@ -39,6 +37,9 @@
|
||||||
|
|
||||||
+ native:
|
+ native:
|
||||||
|
|
||||||
|
- irc: stack underflow?
|
||||||
|
- ignore SIGPIPE
|
||||||
|
- don't allow multiple i/o requests on the same port
|
||||||
- accept multi-line input in listener
|
- accept multi-line input in listener
|
||||||
- gc call in the middle of some ops might affect callstack
|
- gc call in the middle of some ops might affect callstack
|
||||||
- multitasking
|
- multitasking
|
||||||
|
|
|
@ -58,6 +58,7 @@ USE: stdio
|
||||||
"/library/continuations.factor"
|
"/library/continuations.factor"
|
||||||
"/library/platform/native/errors.factor"
|
"/library/platform/native/errors.factor"
|
||||||
"/library/errors.factor"
|
"/library/errors.factor"
|
||||||
|
"/library/platform/native/threads.factor"
|
||||||
"/library/stream.factor"
|
"/library/stream.factor"
|
||||||
"/library/platform/native/io-internals.factor"
|
"/library/platform/native/io-internals.factor"
|
||||||
"/library/platform/native/stream.factor"
|
"/library/platform/native/stream.factor"
|
||||||
|
|
|
@ -53,6 +53,7 @@ primitives,
|
||||||
"/library/continuations.factor"
|
"/library/continuations.factor"
|
||||||
"/library/platform/native/errors.factor"
|
"/library/platform/native/errors.factor"
|
||||||
"/library/errors.factor"
|
"/library/errors.factor"
|
||||||
|
"/library/platform/native/threads.factor"
|
||||||
"/library/stream.factor"
|
"/library/stream.factor"
|
||||||
"/library/platform/native/io-internals.factor"
|
"/library/platform/native/io-internals.factor"
|
||||||
"/library/platform/native/stream.factor"
|
"/library/platform/native/stream.factor"
|
||||||
|
|
|
@ -33,6 +33,7 @@ USE: namespaces
|
||||||
USE: parser
|
USE: parser
|
||||||
USE: stdio
|
USE: stdio
|
||||||
USE: streams
|
USE: streams
|
||||||
|
USE: threads
|
||||||
USE: words
|
USE: words
|
||||||
|
|
||||||
: init-gc ( -- )
|
: init-gc ( -- )
|
||||||
|
@ -42,6 +43,7 @@ USE: words
|
||||||
#! Initialize an interpreter with the basic services.
|
#! Initialize an interpreter with the basic services.
|
||||||
init-gc
|
init-gc
|
||||||
init-namespaces
|
init-namespaces
|
||||||
|
init-threads
|
||||||
init-stdio
|
init-stdio
|
||||||
init-errors
|
init-errors
|
||||||
"HOME" os-env [ "." ] unless* "~" set
|
"HOME" os-env [ "." ] unless* "~" set
|
||||||
|
|
|
@ -32,18 +32,12 @@ USE: kernel
|
||||||
USE: namespaces
|
USE: namespaces
|
||||||
USE: stack
|
USE: stack
|
||||||
USE: strings
|
USE: strings
|
||||||
|
USE: threads
|
||||||
|
|
||||||
: stdin 0 getenv ;
|
: stdin 0 getenv ;
|
||||||
: stdout 1 getenv ;
|
: stdout 1 getenv ;
|
||||||
: stderr 2 getenv ;
|
: stderr 2 getenv ;
|
||||||
|
|
||||||
: yield ( -- )
|
|
||||||
next-io-task dup [
|
|
||||||
call
|
|
||||||
] [
|
|
||||||
drop yield
|
|
||||||
] ifte ;
|
|
||||||
|
|
||||||
: flush-fd ( port -- )
|
: flush-fd ( port -- )
|
||||||
[ swap add-write-io-task yield ] callcc0 drop ;
|
[ swap add-write-io-task yield ] callcc0 drop ;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
! :folding=none:collapseFolds=1:
|
||||||
|
|
||||||
|
! $Id$
|
||||||
|
!
|
||||||
|
! Copyright (C) 2004 Slava Pestov.
|
||||||
|
!
|
||||||
|
! Redistribution and use in source and binary forms, with or without
|
||||||
|
! modification, are permitted provided that the following conditions are met:
|
||||||
|
!
|
||||||
|
! 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
! this list of conditions and the following disclaimer.
|
||||||
|
!
|
||||||
|
! 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
! this list of conditions and the following disclaimer in the documentation
|
||||||
|
! and/or other materials provided with the distribution.
|
||||||
|
!
|
||||||
|
! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||||
|
! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
IN: threads
|
||||||
|
USE: combinators
|
||||||
|
USE: continuations
|
||||||
|
USE: io-internals
|
||||||
|
USE: kernel
|
||||||
|
USE: lists
|
||||||
|
USE: namespaces
|
||||||
|
USE: stack
|
||||||
|
USE: strings
|
||||||
|
|
||||||
|
: run-queue ( -- queue )
|
||||||
|
9 getenv ;
|
||||||
|
|
||||||
|
: set-run-queue ( queue -- )
|
||||||
|
9 setenv ;
|
||||||
|
|
||||||
|
: init-threads ( -- )
|
||||||
|
f set-run-queue ;
|
||||||
|
|
||||||
|
: next-thread ( -- quot )
|
||||||
|
run-queue dup [ uncons set-run-queue ] when ;
|
||||||
|
|
||||||
|
: schedule-thread ( quot -- )
|
||||||
|
run-queue cons set-run-queue ;
|
||||||
|
|
||||||
|
: yield ( -- )
|
||||||
|
next-thread dup [
|
||||||
|
call
|
||||||
|
] [
|
||||||
|
drop next-io-task dup [
|
||||||
|
call
|
||||||
|
] [
|
||||||
|
drop yield
|
||||||
|
] ifte
|
||||||
|
] ifte ;
|
||||||
|
|
||||||
|
: in-thread ( quot -- )
|
||||||
|
[ schedule-thread call yield ] callcc0 drop ;
|
|
@ -95,6 +95,7 @@ USE: strings
|
||||||
"stdio"
|
"stdio"
|
||||||
"strings"
|
"strings"
|
||||||
"test"
|
"test"
|
||||||
|
"threads"
|
||||||
"trace"
|
"trace"
|
||||||
"unparser"
|
"unparser"
|
||||||
"vectors"
|
"vectors"
|
||||||
|
|
|
@ -3,12 +3,13 @@
|
||||||
#define STDIN_ENV 0
|
#define STDIN_ENV 0
|
||||||
#define STDOUT_ENV 1
|
#define STDOUT_ENV 1
|
||||||
#define STDERR_ENV 2
|
#define STDERR_ENV 2
|
||||||
#define NAMESTACK_ENV 3
|
#define NAMESTACK_ENV 3 /* used by library only */
|
||||||
#define GLOBAL_ENV 4
|
#define GLOBAL_ENV 4
|
||||||
#define BREAK_ENV 5
|
#define BREAK_ENV 5
|
||||||
#define CATCHSTACK_ENV 6
|
#define CATCHSTACK_ENV 6 /* used by library only */
|
||||||
#define GC_ENV 7
|
#define GC_ENV 7
|
||||||
#define BOOT_ENV 8
|
#define BOOT_ENV 8
|
||||||
|
#define RUNQUEUE_ENV 9 /* used by library only */
|
||||||
|
|
||||||
/* Error handlers restore this */
|
/* Error handlers restore this */
|
||||||
sigjmp_buf toplevel;
|
sigjmp_buf toplevel;
|
||||||
|
|
Loading…
Reference in New Issue