-;;; Addresses are vectors where the first part is the actor-id and
-;;; the second part is the hive-id. This works well enough... they
-;;; look decent being pretty-printed.
-
-(define (make-address actor-id hive-id channel dead?)
- (vector actor-id hive-id channel dead?))
-
-(define (address-actor-id address)
- (vector-ref address 0))
-
-(define (address-hive-id address)
- (vector-ref address 1))
-
-(define (address-channel address)
- (vector-ref address 2))
-
-(define (address-dead? address)
- (vector-ref address 3))
+;;; Every actor has an address, which is how its identified.
+;;; We also pack in some routing information.
+(define-record-type <address>
+ (make-address actor-id hive-id channel dead?)
+ address?
+ ;; Unique-to-this-actor-on-this-hive part
+ (actor-id address-actor-id)
+ ;; Unique identifier for the hive we're connected to.
+ ;; If we don't have a "direct" link to the other actor through
+ ;; a channel, we'll have to look up if our hive has a way to route
+ ;; to the other hive.
+ (hive-id address-hive-id)
+ ;; The receiving channel (as opposed to actor-inbox-deq)
+ (channel address-channel)
+ ;; A fibers condition variable which is set once this actor kicks
+ ;; the bucket
+ (dead? address-dead?))
+
+(set-record-type-printer!
+ <address>
+ (lambda (address port)
+ (format port "<address ~a ~a>"
+ (address->string address)
+ (if (address-channel address)
+ (string-append
+ ":local"
+ (if (atomic-box-ref
+ ((@@ (fibers conditions) condition-signalled?)
+ (address-dead? address)))
+ " :dead" ""))
+ ":remote"))))