From 2fafbc4b7955225b478c5edf31ae7fdc8d7ee95d Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 18 Jul 2013 17:22:24 -0600 Subject: [PATCH] adjust the places <-> distributed-places connection Instead of a dynamic-require, the connection goes through a structure-type property on a `remote-note%' instance. --- .../distributed-places-doc/info.rkt | 9 ++++++ .../distributed-places.scrbl} | 21 ++++++++----- .../scribblings/distributed-places/info.rkt | 3 ++ .../distributed-places}/rmpi.scrbl | 0 .../distributed-places-lib/info.rkt | 0 .../racket/place/define-remote-server.rkt | 0 .../racket/place/distributed.rkt | 21 ++++++++----- .../distributed/examples/hello-world.rkt | 0 .../distributed/examples/logging/bank.rkt | 0 .../distributed/examples/logging/master.rkt | 0 .../distributed/examples/logging/tuple.rkt | 0 .../distributed/examples/multiple/bank.rkt | 0 .../distributed/examples/multiple/master.rkt | 0 .../examples/multiple/place-worker.rkt | 0 .../place/distributed/examples/named/bank.rkt | 0 .../distributed/examples/named/master.rkt | 0 .../distributed/examples/named/tuple.rkt | 0 .../distributed/examples/restart/master.rkt | 0 .../examples/restart/restarter.rkt | 0 .../distributed/examples/thread/master.rkt | 0 .../racket/place/distributed/info.rkt | 0 .../racket/place/distributed/launch.rkt | 0 .../racket/place/distributed/map-reduce.rkt | 0 .../racket/place/distributed/rmpi.rkt | 0 pkgs/main-distribution/info.rkt | 1 + pkgs/racket-pkgs/racket-doc/info.rkt | 3 +- .../scribblings/reference/concurrency.scrbl | 1 - .../scribblings/reference/places.scrbl | 31 +++++++++++++++++-- racket/lib/collects/racket/place.rkt | 24 ++++++++------ 29 files changed, 85 insertions(+), 29 deletions(-) create mode 100644 pkgs/distributed-places-pkgs/distributed-places-doc/info.rkt rename pkgs/{racket-pkgs/racket-doc/scribblings/reference/distributed.scrbl => distributed-places-pkgs/distributed-places-doc/scribblings/distributed-places/distributed-places.scrbl} (98%) create mode 100644 pkgs/distributed-places-pkgs/distributed-places-doc/scribblings/distributed-places/info.rkt rename pkgs/{racket-pkgs/racket-doc/scribblings/reference => distributed-places-pkgs/distributed-places-doc/scribblings/distributed-places}/rmpi.scrbl (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/info.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/define-remote-server.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed.rkt (99%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/examples/hello-world.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/examples/logging/bank.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/examples/logging/master.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/examples/logging/tuple.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/examples/multiple/bank.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/examples/multiple/master.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/examples/multiple/place-worker.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/examples/named/bank.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/examples/named/master.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/examples/named/tuple.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/examples/restart/master.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/examples/restart/restarter.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/examples/thread/master.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/info.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/launch.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/map-reduce.rkt (100%) rename pkgs/{ => distributed-places-pkgs}/distributed-places-lib/racket/place/distributed/rmpi.rkt (100%) diff --git a/pkgs/distributed-places-pkgs/distributed-places-doc/info.rkt b/pkgs/distributed-places-pkgs/distributed-places-doc/info.rkt new file mode 100644 index 0000000000..1cffae62b8 --- /dev/null +++ b/pkgs/distributed-places-pkgs/distributed-places-doc/info.rkt @@ -0,0 +1,9 @@ +#lang info + +(define collection 'multi) + +(define deps '("base" + "distributed-places-lib" + "racket-doc" + "sandbox-lib" + "scribble-lib")) diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/reference/distributed.scrbl b/pkgs/distributed-places-pkgs/distributed-places-doc/scribblings/distributed-places/distributed-places.scrbl similarity index 98% rename from pkgs/racket-pkgs/racket-doc/scribblings/reference/distributed.scrbl rename to pkgs/distributed-places-pkgs/distributed-places-doc/scribblings/distributed-places/distributed-places.scrbl index 830505c502..07daff6301 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/reference/distributed.scrbl +++ b/pkgs/distributed-places-pkgs/distributed-places-doc/scribblings/distributed-places/distributed-places.scrbl @@ -6,7 +6,7 @@ racket/place/distributed racket/sandbox racket/class - (except-in "mz.rkt" log-message) + (only-in scribblings/reference/mz guidealso) (for-label (except-in racket/base log-message) racket/place/define-remote-server racket/place/distributed @@ -24,6 +24,8 @@ @title[#:tag "distributed-places"]{Distributed Places} +@author{Kevin Tew} + @guidealso["distributed-places"] @defmodule[racket/place/distributed] @@ -154,7 +156,8 @@ the @racket[remote-connection%] instance to respawn the place on the remote node should it exit or terminate at any time. It can also be a procedure of zero arguments to implement the restart procedure, or it can be an object that support a @racket[restart] method that takes a -@tech{place} argument.} +@tech[#:doc '(lib "scribblings/reference/reference.scrbl")]{place} +argument.} @defproc[(spawn-node-supervise-place-at [hostname string?] @@ -379,13 +382,15 @@ node's message router. @defclass[remote-node% object% (event-container<%>)]{ - The @racket[node%] instance controls a distributed places node. It - launches compute places and routes inter-node place messages in the - distributed system. This is the remote api to a distributed places + Like @racket[node%], but for the remote API to a distributed places node. Instances of @racket[remote-node%] are returned by - @racket[spawn-remote-racket-node], - @racket[spawn-node-supervise-dynamic-place-at], and - @racket[spawn-node-supervise-place-thunk-at]. + @racket[create-place-node], @racket[spawn-remote-racket-node], and + @racket[spawn-node-supervise-place-at]. + + A @racket[remote-node%] is a @tech[#:doc '(lib + "scribblings/reference/reference.scrbl")]{place location} in the + sense of @racket[place-location?], which means that it can be + supplied as the @racket[#:at] argument to @racket[dynamic-place]. @defconstructor[([listen-port tcp-listen-port? #f] [restart-on-exit any/c #f])]{ diff --git a/pkgs/distributed-places-pkgs/distributed-places-doc/scribblings/distributed-places/info.rkt b/pkgs/distributed-places-pkgs/distributed-places-doc/scribblings/distributed-places/info.rkt new file mode 100644 index 0000000000..d69a699607 --- /dev/null +++ b/pkgs/distributed-places-pkgs/distributed-places-doc/scribblings/distributed-places/info.rkt @@ -0,0 +1,3 @@ +#lang info + +(define scribblings '(("distributed-places.scrbl" () (net-library)))) diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/reference/rmpi.scrbl b/pkgs/distributed-places-pkgs/distributed-places-doc/scribblings/distributed-places/rmpi.scrbl similarity index 100% rename from pkgs/racket-pkgs/racket-doc/scribblings/reference/rmpi.scrbl rename to pkgs/distributed-places-pkgs/distributed-places-doc/scribblings/distributed-places/rmpi.scrbl diff --git a/pkgs/distributed-places-lib/info.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/info.rkt similarity index 100% rename from pkgs/distributed-places-lib/info.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/info.rkt diff --git a/pkgs/distributed-places-lib/racket/place/define-remote-server.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/define-remote-server.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/define-remote-server.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/define-remote-server.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed.rkt similarity index 99% rename from pkgs/distributed-places-lib/racket/place/distributed.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed.rkt index 9ef59e9f7b..a8833cc43f 100644 --- a/pkgs/distributed-places-lib/racket/place/distributed.rkt +++ b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed.rkt @@ -812,10 +812,17 @@ (super-new) ))) +(define place-location<%> + (interface* + () + ([prop:place-location + (lambda (remote-node place-path place-func named) + (supervise-place-at remote-node place-path place-func + #:named named))]))) + (define remote-node% (backlink - (class* - object% (event-container<%> event<%>) + (class* object% (event-container<%> event<%> place-location<%>) (init-field host-name) (init-field listen-port) (init-field [cmdline-list #f]) @@ -1464,11 +1471,11 @@ #:use-current-ports use-current-ports)) (define (supervise-place-at remote-node place-path place-func - ;#:initial-message [initial-message #f] - #:restart-on-exit [restart-on-exit #f] - #:named [named #f] - #:thunk [thunk #f]) - + ;;#:initial-message [initial-message #f] + #:restart-on-exit [restart-on-exit #f] + #:named [named #f] + #:thunk [thunk #f]) + (send remote-node launch-place (mk-place-creation-addr place-path place-func named thunk) #:restart-on-exit restart-on-exit diff --git a/pkgs/distributed-places-lib/racket/place/distributed/examples/hello-world.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/hello-world.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/examples/hello-world.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/hello-world.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/examples/logging/bank.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/logging/bank.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/examples/logging/bank.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/logging/bank.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/examples/logging/master.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/logging/master.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/examples/logging/master.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/logging/master.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/examples/logging/tuple.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/logging/tuple.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/examples/logging/tuple.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/logging/tuple.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/examples/multiple/bank.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/multiple/bank.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/examples/multiple/bank.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/multiple/bank.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/examples/multiple/master.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/multiple/master.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/examples/multiple/master.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/multiple/master.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/examples/multiple/place-worker.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/multiple/place-worker.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/examples/multiple/place-worker.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/multiple/place-worker.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/examples/named/bank.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/named/bank.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/examples/named/bank.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/named/bank.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/examples/named/master.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/named/master.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/examples/named/master.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/named/master.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/examples/named/tuple.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/named/tuple.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/examples/named/tuple.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/named/tuple.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/examples/restart/master.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/restart/master.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/examples/restart/master.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/restart/master.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/examples/restart/restarter.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/restart/restarter.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/examples/restart/restarter.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/restart/restarter.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/examples/thread/master.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/thread/master.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/examples/thread/master.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/examples/thread/master.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/info.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/info.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/info.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/info.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/launch.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/launch.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/launch.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/launch.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/map-reduce.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/map-reduce.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/map-reduce.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/map-reduce.rkt diff --git a/pkgs/distributed-places-lib/racket/place/distributed/rmpi.rkt b/pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/rmpi.rkt similarity index 100% rename from pkgs/distributed-places-lib/racket/place/distributed/rmpi.rkt rename to pkgs/distributed-places-pkgs/distributed-places-lib/racket/place/distributed/rmpi.rkt diff --git a/pkgs/main-distribution/info.rkt b/pkgs/main-distribution/info.rkt index 9317c3ac4f..b16748d9de 100644 --- a/pkgs/main-distribution/info.rkt +++ b/pkgs/main-distribution/info.rkt @@ -44,6 +44,7 @@ "r5rs" "r6rs" "racket-doc" + "distributed-places-doc" "racket-index" "racket-lib" "racklog" diff --git a/pkgs/racket-pkgs/racket-doc/info.rkt b/pkgs/racket-pkgs/racket-doc/info.rkt index 73914f11ef..e1c48cb74d 100644 --- a/pkgs/racket-pkgs/racket-doc/info.rkt +++ b/pkgs/racket-pkgs/racket-doc/info.rkt @@ -35,4 +35,5 @@ "syntax-color" "scribble" "compatibility-lib" - "future-visualizer")) + "future-visualizer" + "distributed-places-doc")) diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/reference/concurrency.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/reference/concurrency.scrbl index 2d7f08e211..a7e016aa8a 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/reference/concurrency.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/reference/concurrency.scrbl @@ -18,5 +18,4 @@ support for parallelism to improve performance. @include-section["thread-local.scrbl"] @include-section["futures.scrbl"] @include-section["places.scrbl"] -@include-section["distributed.scrbl"] @include-section["engine.scrbl"] diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/reference/places.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/reference/places.scrbl index b7aea76580..d6c0dc7b0c 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/reference/places.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/reference/places.scrbl @@ -11,7 +11,8 @@ racket/place racket/future racket/flonum - racket/fixnum)) + racket/fixnum + (only-in racket/place/distributed create-place-node))) @; ---------------------------------------------------------------------- @@ -127,8 +128,10 @@ are simulated using @racket[thread].} @defproc[(dynamic-place [module-path (or/c module-path? path?)] - [start-name symbol?]) - place?]{ + [start-name symbol?] + [#:at location (or/c #f place-location?) #f] + [#:named named any/c #f]) + place?]{ Creates a @tech{place} to run the procedure that is identified by @racket[module-path] and @racket[start-name]. The result is a @@ -143,6 +146,9 @@ are simulated using @racket[thread].} other end of communication for the @tech{place descriptor} returned by @racket[place]. +If @racket[location] is provided, it must be a @tech{place location}, +such as a distributed places node produced by @racket[create-place-node]. + When the @tech{place} is created, the initial @tech{exit handler} terminates the place, using the argument to the exit handler as the place's @deftech{completion value}. Use @racket[(exit _v)] to @@ -357,4 +363,23 @@ messages: ]} +@deftogether[( +@defthing[prop:place-location struct-type-property?] +@defproc[(place-location? [v any/c]) boolean?] +)]{ + +A @tech{structure type property} and associated predicate for +implementations of @deftech{place locations}. The value of +@racket[prop:place-location] must be a procedure of four arguments: +the @tech{place location} itself, a module path, a symbol for the +start function exported by the module, and a place name (which can be +@racket[#f] for an anonymous place). + +A @tech{place location} can be passed as the @racket[#:at] argument to +@racket[dynamic-place], which in turn simply calls the +@racket[prop:place-location] value of the @tech{place location}. + +A distributed places note created with @racket[create-place-node] +is an example of a @tech{place location}.} + @;------------------------------------------------------------------------ diff --git a/racket/lib/collects/racket/place.rkt b/racket/lib/collects/racket/place.rkt index 056ec3d1de..c0f4b9ba2f 100644 --- a/racket/lib/collects/racket/place.rkt +++ b/racket/lib/collects/racket/place.rkt @@ -10,7 +10,6 @@ racket/place/private/th-place racket/place/private/prop racket/private/streams - racket/lazy-require (for-syntax racket/base @@ -34,7 +33,8 @@ place* (rename-out [pl-place-enabled? place-enabled?]) place-dead-evt - ) + place-location? + prop:place-location) (define-syntax (define-pl-func stx) (syntax-case stx () @@ -48,8 +48,6 @@ [(pl-place-enabled?) (pl-func p args ...)] [else (th-func p args ...)])))])) -(lazy-require [racket/place/distributed (supervise-place-at)]) - (define (place-channel-put/get ch msg) (place-channel-put ch msg) (place-channel-get ch)) @@ -67,6 +65,16 @@ (define-pl-func place-message-allowed? p) (define-pl-func place-dead-evt p) +(define-values (prop:place-location place-location? place-location-ref) + (make-struct-type-property 'place-location + (lambda (v info) + (unless (and (procedure? v) + (procedure-arity-includes? v 4)) + (raise-argument-error 'guard-for-prop:place-location + "(procedure-arity-includes/c 4)" + v)) + v))) + (define place-break/opt (let ([place-break (lambda (p [kind #f]) (place-break p kind))]) place-break)) @@ -81,11 +89,9 @@ (define (dynamic-place module-path function #:at [node #f] #:named [named #f]) (cond [node - (unless (collection-file-path "distributed.rkt" "racket" "place" - #:fail (lambda (x) #f)) - (raise-arguments-error "dynamic-place" - "distributed places are not available")) - (supervise-place-at node module-path function #:named named)] + (unless (place-location? node) + (raise-argument-error 'dynamic-place "(or/c place-location? #f)" node)) + ((place-location-ref node) node module-path function named)] [else (start-place 'dynamic-place module-path function #f (current-output-port) (current-error-port))]))