(declare (block) (standard-bindings) (extended-bindings))
(begin
  (define std/actor/message#actor-error::t
    (make-struct-type
     'std/actor/message#actor-error::t
     error::t
     '0
     'actor-error
     '()
     ':init!
     '()))
  (define std/actor/message#actor-error?
    (make-struct-predicate std/actor/message#actor-error::t))
  (define std/actor/message#make-actor-error
    (lambda _$args2241_
      (apply make-struct-instance
             std/actor/message#actor-error::t
             _$args2241_)))
  (define std/actor/message#actor-error:::init!
    (lambda (_self2236_ _where2237_ _what2238_ . _irritants2239_)
      (if (let ((__tmp6105
                 (let () (declare (not safe)) (##vector-length _self2236_))))
            (declare (not safe))
            (##fx< '3 __tmp6105))
          (begin
            (let ()
              (declare (not safe))
              (##vector-set! _self2236_ '1 _what2238_))
            (let ()
              (declare (not safe))
              (##vector-set! _self2236_ '2 _irritants2239_))
            (let ()
              (declare (not safe))
              (##vector-set! _self2236_ '3 _where2237_)))
          (error '"struct-instance-init!: too many arguments for struct"
                 _self2236_))))
  (bind-method!
   std/actor/message#actor-error::t
   ':init!
   std/actor/message#actor-error:::init!
   '#f)
  (define std/actor/message#message::t
    (make-struct-type
     'std/actor/message#message::t
     '#f
     '4
     'message
     '((final: . #t))
     '#f
     '(e source dest options)))
  (define std/actor/message#message?
    (make-struct-predicate std/actor/message#message::t))
  (define std/actor/message#make-message
    (lambda _$args2111_
      (apply make-struct-instance std/actor/message#message::t _$args2111_)))
  (define std/actor/message#message-e
    (make-struct-field-accessor std/actor/message#message::t '0))
  (define std/actor/message#message-source
    (make-struct-field-accessor std/actor/message#message::t '1))
  (define std/actor/message#message-dest
    (make-struct-field-accessor std/actor/message#message::t '2))
  (define std/actor/message#message-options
    (make-struct-field-accessor std/actor/message#message::t '3))
  (define std/actor/message#message-e-set!
    (make-struct-field-mutator std/actor/message#message::t '0))
  (define std/actor/message#message-source-set!
    (make-struct-field-mutator std/actor/message#message::t '1))
  (define std/actor/message#message-dest-set!
    (make-struct-field-mutator std/actor/message#message::t '2))
  (define std/actor/message#message-options-set!
    (make-struct-field-mutator std/actor/message#message::t '3))
  (define std/actor/message#proxy::t
    (make-struct-type
     'std/actor/message#proxy::t
     '#f
     '1
     'proxy
     '()
     '#f
     '(handler)))
  (define std/actor/message#proxy?
    (make-struct-predicate std/actor/message#proxy::t))
  (define std/actor/message#make-proxy
    (lambda _$args2108_
      (apply make-struct-instance std/actor/message#proxy::t _$args2108_)))
  (define std/actor/message#proxy-handler
    (make-struct-field-accessor std/actor/message#proxy::t '0))
  (define std/actor/message#proxy-handler-set!
    (make-struct-field-mutator std/actor/message#proxy::t '0))
  (define std/actor/message#send__%
    (lambda (_dest2085_ _msg2086_ _raise-dead?2087_)
      (let _lp2089_ ((_dest2091_ _dest2085_))
        (if (thread? _dest2091_)
            (let ((_$e2093_
                   (std/actor/message#thread-send/check _dest2091_ _msg2086_)))
              (if _$e2093_
                  _$e2093_
                  (if (not _raise-dead?2087_)
                      '#f
                      (raise (make-struct-instance
                              std/actor/message#actor-error::t
                              'send
                              '"Cannot send message; dead thread"
                              _dest2091_
                              _msg2086_)))))
            (if (let ()
                  (declare (not safe))
                  (##structure-instance-of?
                   _dest2091_
                   'std/actor/message#proxy::t))
                (_lp2089_
                 (##structure-ref
                  _dest2091_
                  '1
                  std/actor/message#proxy::t
                  '#f))
                (_lp2089_
                 (let* ((__self6103 ':actor)
                        (__method6104 (method-ref __self6103 _dest2091_)))
                   (if __method6104
                       (__method6104 __self6103)
                       (error '"Missing method" __self6103 _dest2091_)))))))))
  (define std/actor/message#send__0
    (lambda (_dest2099_ _msg2100_)
      (let ((_raise-dead?2102_ '#f))
        (std/actor/message#send__% _dest2099_ _msg2100_ _raise-dead?2102_))))
  (define std/actor/message#send
    (lambda _g6107_
      (let ((_g6106_ (let () (declare (not safe)) (##length _g6107_))))
        (cond ((let () (declare (not safe)) (##fx= _g6106_ 2))
               (apply std/actor/message#send__0 _g6107_))
              ((let () (declare (not safe)) (##fx= _g6106_ 3))
               (apply std/actor/message#send__% _g6107_))
              (else
               (##raise-wrong-number-of-arguments-exception
                std/actor/message#send
                _g6107_))))))
  (define std/actor/message#send-message__%
    (lambda (_dest2058_ _value2059_ _options2060_ _check-dead?2061_)
      (std/actor/message#send__%
       _dest2058_
       (let ((__tmp6108 (current-thread)))
         (declare (not safe))
         (##structure
          std/actor/message#message::t
          _value2059_
          __tmp6108
          _dest2058_
          _options2060_))
       _check-dead?2061_)))
  (define std/actor/message#send-message__0
    (lambda (_dest2066_ _value2067_)
      (let* ((_options2069_ '#f)
             (_check-dead?2071_
              (let ()
                (declare (not safe))
                (##structure-instance-of?
                 _dest2066_
                 'std/actor/message#proxy::t))))
        (std/actor/message#send-message__%
         _dest2066_
         _value2067_
         _options2069_
         _check-dead?2071_))))
  (define std/actor/message#send-message__1
    (lambda (_dest2073_ _value2074_ _options2075_)
      (let ((_check-dead?2077_
             (let ()
               (declare (not safe))
               (##structure-instance-of?
                _dest2073_
                'std/actor/message#proxy::t))))
        (std/actor/message#send-message__%
         _dest2073_
         _value2074_
         _options2075_
         _check-dead?2077_))))
  (define std/actor/message#send-message
    (lambda _g6110_
      (let ((_g6109_ (let () (declare (not safe)) (##length _g6110_))))
        (cond ((let () (declare (not safe)) (##fx= _g6109_ 2))
               (apply std/actor/message#send-message__0 _g6110_))
              ((let () (declare (not safe)) (##fx= _g6109_ 3))
               (apply std/actor/message#send-message__1 _g6110_))
              ((let () (declare (not safe)) (##fx= _g6109_ 4))
               (apply std/actor/message#send-message__% _g6110_))
              (else
               (##raise-wrong-number-of-arguments-exception
                std/actor/message#send-message
                _g6110_))))))
  (define std/actor/message#send-message/timeout__%
    (lambda (_dest2038_ _value2039_ _timeo2040_ _check-dead?2041_)
      (std/actor/message#send__%
       _dest2038_
       (let ((__tmp6112 (current-thread))
             (__tmp6111 (cons 'timeout: (cons _timeo2040_ '()))))
         (declare (not safe))
         (##structure
          std/actor/message#message::t
          _value2039_
          __tmp6112
          _dest2038_
          __tmp6111))
       _check-dead?2041_)))
  (define std/actor/message#send-message/timeout__0
    (lambda (_dest2046_ _value2047_ _timeo2048_)
      (let ((_check-dead?2050_
             (let ()
               (declare (not safe))
               (##structure-instance-of?
                _dest2046_
                'std/actor/message#proxy::t))))
        (std/actor/message#send-message/timeout__%
         _dest2046_
         _value2047_
         _timeo2048_
         _check-dead?2050_))))
  (define std/actor/message#send-message/timeout
    (lambda _g6114_
      (let ((_g6113_ (let () (declare (not safe)) (##length _g6114_))))
        (cond ((let () (declare (not safe)) (##fx= _g6113_ 3))
               (apply std/actor/message#send-message/timeout__0 _g6114_))
              ((let () (declare (not safe)) (##fx= _g6113_ 4))
               (apply std/actor/message#send-message/timeout__% _g6114_))
              (else
               (##raise-wrong-number-of-arguments-exception
                std/actor/message#send-message/timeout
                _g6114_))))))
  (namespace ("std/actor/message#" send thread-send/check))
  (define (thread-send/check thread msg)
    (declare (not interrupts-enabled))
    (macro-check-initialized-thread
     thread
     (send thread msg)
     (if (macro-thread-end-condvar thread) (##thread-send thread msg) #f)))
  (define std/actor/message#receive-timeout
    (lambda _args1973_
      (letrec* ((_now1975_ '#f))
        (let _lp1977_ ((_rest1979_ _args1973_)
                       (_timeo1980_ absent-obj)
                       (_deadline1981_ '#f)
                       (_K1982_ void))
          (let* ((_rest19831993_ _rest1979_)
                 (_else19852001_ (lambda () (values _timeo1980_ _K1982_)))
                 (_K19872018_
                  (lambda (_rest2004_ _k2005_ _evt2006_)
                    (if (not _evt2006_)
                        (_lp1977_
                         _rest2004_
                         _timeo1980_
                         _deadline1981_
                         _K1982_)
                        (if (time? _evt2006_)
                            (let ((_evt-deadline2008_
                                   (time->seconds _evt2006_)))
                              (if (or (not _deadline1981_)
                                      (< _evt-deadline2008_ _deadline1981_))
                                  (_lp1977_
                                   _rest2004_
                                   _evt2006_
                                   _evt-deadline2008_
                                   _k2005_)
                                  (_lp1977_
                                   _rest2004_
                                   _timeo1980_
                                   _deadline1981_
                                   _K1982_)))
                            (if (real? _evt2006_)
                                (begin
                                  (if _now1975_
                                      '#!void
                                      (set! _now1975_
                                            (let ()
                                              (declare (not safe))
                                              (##current-time-point))))
                                  (let ((_evt-deadline2013_
                                         (+ _now1975_ _evt2006_)))
                                    (if (or (not _deadline1981_)
                                            (< _evt-deadline2013_
                                               _deadline1981_))
                                        (_lp1977_
                                         _rest2004_
                                         (seconds->time _evt-deadline2013_)
                                         _evt-deadline2013_
                                         _k2005_)
                                        (_lp1977_
                                         _rest2004_
                                         _timeo1980_
                                         _deadline1981_
                                         _K1982_))))
                                (error '"Illegal event; expected time, real, or #f"
                                       _evt2006_)))))))
            (if (let () (declare (not safe)) (##pair? _rest19831993_))
                (let ((_hd19882021_
                       (let () (declare (not safe)) (##car _rest19831993_)))
                      (_tl19892023_
                       (let () (declare (not safe)) (##cdr _rest19831993_))))
                  (let ((_evt2026_ _hd19882021_))
                    (if (let () (declare (not safe)) (##pair? _tl19892023_))
                        (let ((_hd19902028_
                               (let ()
                                 (declare (not safe))
                                 (##car _tl19892023_)))
                              (_tl19912030_
                               (let ()
                                 (declare (not safe))
                                 (##cdr _tl19892023_))))
                          (let* ((_k2033_ _hd19902028_)
                                 (_rest2035_ _tl19912030_))
                            (_K19872018_ _rest2035_ _k2033_ _evt2026_)))
                        (_else19852001_))))
                (_else19852001_)))))))
  (define std/actor/message#mailbox-timeout '#(timeout))
  (namespace ("std/actor/message#" mailbox-empty mailbox-next))
  (define mailbox-empty '#(empty))
  (define (mailbox-next)
    (declare (not interrupts-enabled))
    (let* ((mb (##thread-mailbox-get! (macro-current-thread)))
           (cursor (macro-mailbox-cursor mb))
           (next (if cursor (macro-fifo-next cursor) (macro-mailbox-fifo mb)))
           (next2 (macro-fifo-next next)))
      (if (##pair? next2)
          (let ((result (macro-fifo-elem next2)))
            (macro-mailbox-cursor-set! mb next)
            result)
          mailbox-empty))))
