release
Slava Pestov 2007-11-14 17:04:29 -05:00
parent eafa0d792c
commit d6f4b25abe
2 changed files with 13 additions and 10 deletions

2
extra/destructors/destructors-docs.factor Normal file → Executable file
View File

@ -23,7 +23,7 @@ HELP: close-later
HELP: with-destructors
{ $values { "quot" "a quotation" } }
{ $description "Calls a quotation within a new dynamic scope. This quotation may register destructors, on any object, by wrapping the object in a destructor and implementing " { $link (destruct) } " on that object type. After the quotation finishes, if an error was thrown, all destructors are called and the error is then rethrown. However, if the quotation was successful, only those destructors created with an 'always cleanup' flag will be destroyed." }
{ $description "Calls a quotation within a new dynamic scope. This quotation may register destructors, on any object, by wrapping the object in a destructor and implementing " { $link destruct } " on that object type. After the quotation finishes, if an error was thrown, all destructors are called and the error is then rethrown. However, if the quotation was successful, only those destructors created with an 'always cleanup' flag will be destroyed." }
{ $notes "Destructors are not allowed to throw exceptions. No exceptions." }
{ $examples
{ $code "[ 10 malloc free-always ] with-destructors" }

View File

@ -2,7 +2,8 @@ USING: alien alien.c-types arrays assocs combinators
continuations destructors io io.backend io.nonblocking
io.windows libc kernel math namespaces sequences threads
tuples.lib windows windows.errors windows.kernel32 strings
splitting io.files windows.winsock ;
splitting io.files qualified ;
QUALIFIED: windows.winsock
IN: io.windows.nt.backend
: unicode-prefix ( -- seq )
@ -62,14 +63,16 @@ C: <io-callback> io-callback
: set-port-overlapped ( overlapped port -- )
port-handle set-win32-file-overlapped ;
: completion-port ( handle existing -- handle )
: <completion-port> ( handle existing -- handle )
f 1 CreateIoCompletionPort dup win32-error=0/f ;
: master-completion-port ( -- handle )
INVALID_HANDLE_VALUE f completion-port ;
SYMBOL: master-completion-port
: <master-completion-port> ( -- handle )
INVALID_HANDLE_VALUE f <completion-port> ;
M: windows-nt-io add-completion ( handle -- )
\ master-completion-port get-global completion-port drop ;
master-completion-port get-global <completion-port> drop ;
TUPLE: GetOverlappedResult-args hFile* lpOverlapped* lpNumberOfBytesTransferred* bWait* port ;
@ -98,8 +101,8 @@ TUPLE: GetQueuedCompletionStatusParams hCompletionPort* lpNumberOfBytes* lpCompl
C: <GetQueuedCompletionStatusParams> GetQueuedCompletionStatusParams
: wait-for-overlapped ( ms -- GetQueuedCompletionStatus-Params ret )
>r \ master-completion-port get-global 0 <int>
0 <int> 0 <int> r> <GetQueuedCompletionStatusParams> [
>r master-completion-port get-global 0 <int> 0 <int> 0 <int>
r> <GetQueuedCompletionStatusParams> [
GetQueuedCompletionStatusParams >tuple*<
GetQueuedCompletionStatus
] keep swap ;
@ -146,7 +149,7 @@ M: windows-nt-io init-io ( -- )
#! Should only be called on startup. Calling this at any
#! other time can have unintended consequences.
global [
master-completion-port \ master-completion-port set
<master-completion-port> master-completion-port set
H{ } clone io-hash set
init-winsock
windows.winsock:init-winsock
] bind ;