add custodian-shut-down?
This commit is contained in:
parent
9e3bdaa328
commit
5dec488ec4
|
@ -12,7 +12,7 @@
|
|||
|
||||
(define collection 'multi)
|
||||
|
||||
(define version "6.11.0.4")
|
||||
(define version "6.11.0.5")
|
||||
|
||||
(define deps `("racket-lib"
|
||||
["racket" #:version ,version]))
|
||||
|
|
|
@ -14,7 +14,9 @@ Returns @racket[#t] if @racket[v] is a @tech{custodian} value,
|
|||
@racket[#f] otherwise.}
|
||||
|
||||
|
||||
@defproc[(make-custodian [cust custodian? (current-custodian)]) custodian?]{
|
||||
@defproc[(make-custodian [cust (and/c custodian? (not/c custodian-shut-down?))
|
||||
(current-custodian)])
|
||||
custodian?]{
|
||||
|
||||
Creates a new custodian that is subordinate to @racket[cust]. When
|
||||
@racket[cust] is directed (via @racket[custodian-shutdown-all]) to
|
||||
|
@ -36,7 +38,21 @@ associated with @racket[cust] (and its subordinates). It also removes
|
|||
a thread has no managers, it is killed (or suspended; see
|
||||
@racket[thread/suspend-to-kill]) If the current thread is to be
|
||||
killed, all other shut-down actions take place before killing the
|
||||
thread.}
|
||||
thread.
|
||||
|
||||
If @racket[cust] is already shut down, then
|
||||
@racket[custodian-shutdown-all] has no effect. When a custodian is
|
||||
shut down and it has subordinate custodians, the subordinates are not
|
||||
only shut down, they no longer count as subordinates.}
|
||||
|
||||
|
||||
@defproc[(custodian-shut-down? [cust custodian?]) boolean?]{
|
||||
|
||||
Returns @racket[#t] if @racket[cust] has been shut down with
|
||||
@racket[custodian-shutdown-all] or if it was a subordinate of a
|
||||
custodian that is shut down, @racket[#f] otherwise.
|
||||
|
||||
@history[#:added "6.11.0.5"]}
|
||||
|
||||
|
||||
@defparam[current-custodian cust custodian?]{
|
||||
|
@ -55,7 +71,12 @@ Returns a list of immediately managed objects (not including
|
|||
@tech{custodian box}es) and subordinate custodians for @racket[cust],
|
||||
where @racket[cust] is itself subordinate to @racket[super] (directly
|
||||
or indirectly). If @racket[cust] is not strictly subordinate to
|
||||
@racket[super], the @exnraise[exn:fail:contract].}
|
||||
@racket[super], the @exnraise[exn:fail:contract].
|
||||
|
||||
If @racket[cust] has been shut down, the result is @racket['()]. If
|
||||
@racket[cust] was a subordinate of a custodian that was shut
|
||||
down, then it cannot be a subordinate of @racket[super].}
|
||||
|
||||
|
||||
@defproc[(custodian-memory-accounting-available?) boolean?]{
|
||||
|
||||
|
@ -66,6 +87,7 @@ Racket CGC.}
|
|||
Returns @racket[#t] if Racket is compiled with support for
|
||||
per-custodian memory accounting, @racket[#f] otherwise.}
|
||||
|
||||
|
||||
@defproc[(custodian-require-memory [limit-cust custodian?]
|
||||
[need-amt exact-nonnegative-integer?]
|
||||
[stop-cust custodian?]) void?]{
|
||||
|
@ -77,7 +99,11 @@ support for per-custodian memory accounting, otherwise the
|
|||
If a check is registered, and if Racket later reaches a state after
|
||||
garbage collection (see @secref["gc-model"]) where allocating
|
||||
@racket[need-amt] bytes charged to @racket[limit-cust] would fail or
|
||||
trigger some shutdown, then @racket[stop-cust] is shut down.}
|
||||
trigger some shutdown, then @racket[stop-cust] is shut down.
|
||||
|
||||
The @racket[stop-cust] must be a subordinate custodian of
|
||||
@racket[limit-cust].}
|
||||
|
||||
|
||||
@defproc[(custodian-limit-memory [limit-cust custodian?]
|
||||
[limit-amt exact-nonnegative-integer?]
|
||||
|
@ -114,17 +140,21 @@ immediate allocations can be rejected with an
|
|||
@defproc[(make-custodian-box [cust custodian?] [v any/c]) custodian-box?]{
|
||||
|
||||
Returns a @tech{custodian box} that contains @racket[v] as long as
|
||||
@racket[cust] has not been shut down.
|
||||
@racket[cust] has not been shut down. If @racket[cust] is already
|
||||
shut down, the custodian box's value is immediately removed.
|
||||
|
||||
A @tech{custodian box} is a @tech{synchronizable event} (see @secref["sync"]).
|
||||
The @tech{custodian box} becomes ready when its custodian is shut down;
|
||||
@resultItself{@tech{custodian box}}.}
|
||||
|
||||
|
||||
@defproc[(custodian-box? [v any/c]) boolean?]{Returns @racket[#t] if
|
||||
@racket[v] is a @tech{custodian box} produced by
|
||||
@racket[make-custodian-box], @racket[#f] otherwise.}
|
||||
@defproc[(custodian-box? [v any/c]) boolean?]{
|
||||
|
||||
@defproc[(custodian-box-value [cb custodian-box?]) any]{Returns the
|
||||
value in the given @tech{custodian box}, or @racket[#f] if the value
|
||||
has been removed.}
|
||||
Returns @racket[#t] if @racket[v] is a @tech{custodian box} produced
|
||||
by @racket[make-custodian-box], @racket[#f] otherwise.}
|
||||
|
||||
|
||||
@defproc[(custodian-box-value [cb custodian-box?]) any]{
|
||||
|
||||
Returns the value in the given @tech{custodian box}, or @racket[#f] if
|
||||
the value has been removed.}
|
||||
|
|
|
@ -152,7 +152,9 @@
|
|||
(test #f eq? start result)
|
||||
(test #t thread-running? th1)
|
||||
(test #f thread-dead? th1)
|
||||
(test #f custodian-shut-down? cm)
|
||||
(custodian-shutdown-all cm)
|
||||
(test #t custodian-shut-down? cm)
|
||||
(thread-wait th1)
|
||||
(set! start result)
|
||||
(test #f thread-running? th1)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -14,7 +14,7 @@
|
|||
|
||||
#define USE_COMPILED_STARTUP 1
|
||||
|
||||
#define EXPECTED_PRIM_COUNT 1160
|
||||
#define EXPECTED_PRIM_COUNT 1161
|
||||
#define EXPECTED_UNSAFE_COUNT 156
|
||||
#define EXPECTED_FLFXNUM_COUNT 69
|
||||
#define EXPECTED_EXTFL_COUNT 45
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
consistently.)
|
||||
*/
|
||||
|
||||
#define MZSCHEME_VERSION "6.11.0.4"
|
||||
#define MZSCHEME_VERSION "6.11.0.5"
|
||||
|
||||
#define MZSCHEME_VERSION_X 6
|
||||
#define MZSCHEME_VERSION_Y 11
|
||||
#define MZSCHEME_VERSION_Z 0
|
||||
#define MZSCHEME_VERSION_W 4
|
||||
#define MZSCHEME_VERSION_W 5
|
||||
|
||||
#define MZSCHEME_VERSION_MAJOR ((MZSCHEME_VERSION_X * 100) + MZSCHEME_VERSION_Y)
|
||||
#define MZSCHEME_VERSION_MINOR ((MZSCHEME_VERSION_Z * 1000) + MZSCHEME_VERSION_W)
|
||||
|
|
|
@ -324,6 +324,7 @@ static Scheme_Object *evts_to_evt(int argc, Scheme_Object *args[]);
|
|||
static Scheme_Object *make_custodian(int argc, Scheme_Object *argv[]);
|
||||
static Scheme_Object *custodian_p(int argc, Scheme_Object *argv[]);
|
||||
static Scheme_Object *custodian_close_all(int argc, Scheme_Object *argv[]);
|
||||
static Scheme_Object *custodian_shut_down_p(int argc, Scheme_Object *argv[]);
|
||||
static Scheme_Object *custodian_to_list(int argc, Scheme_Object *argv[]);
|
||||
static Scheme_Object *current_custodian(int argc, Scheme_Object *argv[]);
|
||||
static Scheme_Object *make_custodian_box(int argc, Scheme_Object *argv[]);
|
||||
|
@ -544,6 +545,7 @@ void scheme_init_thread(Scheme_Env *env)
|
|||
GLOBAL_PRIM_W_ARITY("make-custodian" , make_custodian , 0, 1, env);
|
||||
GLOBAL_FOLDING_PRIM("custodian?" , custodian_p , 1, 1, 1 , env);
|
||||
GLOBAL_PRIM_W_ARITY("custodian-shutdown-all", custodian_close_all , 1, 1, env);
|
||||
GLOBAL_PRIM_W_ARITY("custodian-shut-down?" , custodian_shut_down_p, 1, 1, env);
|
||||
GLOBAL_PRIM_W_ARITY("custodian-managed-list", custodian_to_list , 2, 2, env);
|
||||
GLOBAL_PRIM_W_ARITY("make-custodian-box" , make_custodian_box , 2, 2, env);
|
||||
GLOBAL_PRIM_W_ARITY("custodian-box-value" , custodian_box_value , 1, 1, env);
|
||||
|
@ -927,7 +929,7 @@ static Scheme_Object *custodian_limit_mem(int argc, Scheme_Object *args[])
|
|||
|
||||
if (argc > 2) {
|
||||
if (NOT_SAME_TYPE(SCHEME_TYPE(args[2]), scheme_custodian_type)) {
|
||||
scheme_wrong_contract("custodian-require-memory", "custodian?", 2, argc, args);
|
||||
scheme_wrong_contract("custodian-limit-memory", "custodian?", 2, argc, args);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1627,6 +1629,16 @@ static Scheme_Object *custodian_close_all(int argc, Scheme_Object *argv[])
|
|||
return scheme_void;
|
||||
}
|
||||
|
||||
static Scheme_Object *custodian_shut_down_p(int argc, Scheme_Object *argv[])
|
||||
{
|
||||
if (!SCHEME_CUSTODIANP(argv[0]))
|
||||
scheme_wrong_contract("custodian-shut-down?", "custodian?", 0, argc, argv);
|
||||
|
||||
return (((Scheme_Custodian *)argv[0])->shut_down
|
||||
? scheme_true
|
||||
: scheme_false);
|
||||
}
|
||||
|
||||
Scheme_Custodian* scheme_custodian_extract_reference(Scheme_Custodian_Reference *mr)
|
||||
{
|
||||
return CUSTODIAN_FAM(mr);
|
||||
|
|
Loading…
Reference in New Issue
Block a user