#ifndef __X10_LANG_RUNTIME_H
#define __X10_LANG_RUNTIME_H

#include <x10rt.h>


#define X10_LANG_OBJECT_H_NODEPS
#include <x10/lang/Object.h>
#undef X10_LANG_OBJECT_H_NODEPS
namespace x10 { namespace lang { 
class Any;
} } 
namespace x10 { namespace compiler { 
class Native;
} } 
namespace x10 { namespace lang { 
class String;
} } 
namespace x10 { namespace lang { 
class Int;
} } 
namespace x10 { namespace lang { 
class Boolean;
} } 
namespace x10 { namespace util { 
template<class TPMGL(K), class TPMGL(V)> class HashMap;
} } 
namespace x10 { namespace lang { 
class VoidFun_0_0;
} } 
namespace x10 { namespace lang { 
class FinishState;
} } 
namespace x10 { namespace lang { 
class Long;
} } 
namespace x10 { namespace lang { 
class Runtime__X10RTStats;
} } 
namespace x10 { namespace lang { 
class Runtime__X10RTMessageStats;
} } 
namespace x10 { namespace lang { 
template<class TPMGL(U)> class Fun_0_0;
} } 
namespace x10 { namespace util { 
class NoSuchElementException;
} } 
namespace x10 { namespace lang { 
class NumberFormatException;
} } 
namespace x10 { namespace util { namespace concurrent { 
class Monitor;
} } } 
namespace x10 { namespace compiler { 
class PerProcess;
} } 
namespace x10 { namespace lang { 
class Runtime__Pool;
} } 
namespace x10 { namespace lang { 
class Deque;
} } 
namespace x10 { namespace lang { 
class Runtime__Worker;
} } 
namespace x10 { namespace lang { 
class FinishState__FinishStates;
} } 
namespace x10 { namespace lang { 
class Thread;
} } 
namespace x10 { namespace lang { 
class Activity;
} } 
namespace x10 { namespace lang { 
class Place;
} } 
namespace x10 { namespace lang { 
class Throwable;
} } 
namespace x10 { namespace lang { 
class FinishState__Finish;
} } 
namespace x10 { namespace lang { 
class RuntimeException;
} } 
namespace x10 { namespace compiler { 
class Finalization;
} } 
namespace x10 { namespace compiler { 
class Abort;
} } 
namespace x10 { namespace compiler { 
class CompilerFlags;
} } 
namespace x10 { namespace lang { 
class FinishState__FinishSkeleton;
} } 
namespace x10 { namespace util { namespace concurrent { 
class SimpleLatch;
} } } 
namespace x10 { namespace compiler { 
class RemoteInvocation;
} } 
namespace x10 { namespace array { 
template<class TPMGL(T)> class Array;
} } 
namespace x10 { namespace lang { 
class Clock;
} } 
namespace x10 { namespace lang { 
class Activity__ClockPhases;
} } 
namespace x10 { namespace lang { 
class FinishState__UncountedFinish;
} } 
namespace x10 { namespace lang { 
class Runtime__RemoteControl;
} } 
namespace x10 { namespace compiler { 
class StackAllocate;
} } 
namespace x10 { namespace lang { 
template<class TPMGL(T)> class GlobalRef;
} } 
namespace x10 { namespace compiler { 
class AsyncClosure;
} } 
namespace x10 { namespace lang { 
template<class TPMGL(T)> class Runtime__Remote;
} } 
namespace x10 { namespace util { 
template<class TPMGL(T)> class Box;
} } 
namespace x10 { namespace util { namespace concurrent { 
class Lock;
} } } 
namespace x10 { namespace compiler { 
class Pragma;
} } 
namespace x10 { namespace lang { 
class FinishState__FinishAsync;
} } 
namespace x10 { namespace lang { 
class FinishState__FinishHere;
} } 
namespace x10 { namespace lang { 
class FinishState__FinishSPMD;
} } 
namespace x10 { namespace lang { 
class FinishState__LocalFinish;
} } 
namespace x10 { namespace lang { 
template<class TPMGL(T)> class Reducible;
} } 
namespace x10 { namespace lang { 
template<class TPMGL(T)> class FinishState__CollectingFinish;
} } 
namespace x10 { namespace compiler { 
class Pinned;
} } 
namespace x10 { namespace lang { 

class Runtime : public x10::lang::Object   {
    public:
    RTT_H_DECLS_CLASS
    
    static x10_int FMGL(PLATFORM_MAX_THREADS);
    
    static void FMGL(PLATFORM_MAX_THREADS__do_init)();
    static void FMGL(PLATFORM_MAX_THREADS__init)();
    static volatile x10aux::status FMGL(PLATFORM_MAX_THREADS__status);
    static x10_int FMGL(PLATFORM_MAX_THREADS__get)();
    static x10aux::ref<x10::lang::Reference> FMGL(PLATFORM_MAX_THREADS__deserialize)(x10aux::deserialization_buffer &buf);
    static const x10aux::serialization_id_t FMGL(PLATFORM_MAX_THREADS__id);
    
    static x10_boolean FMGL(DEFAULT_STATIC_THREADS);
    
    static x10_boolean FMGL(DEFAULT_STATIC_THREADS__get)();
    static void runClosureAt(x10_int id, x10aux::ref<x10::lang::VoidFun_0_0> body);
    static void runClosureAt(x10_int id, x10aux::ref<x10::lang::VoidFun_0_0> body,
                             x10_int endpoint);
    static void runClosureCopyAt(x10_int id, x10aux::ref<x10::lang::VoidFun_0_0> body);
    static void runClosureCopyAt(x10_int id, x10aux::ref<x10::lang::VoidFun_0_0> body,
                                 x10_int endpoint);
    static void runAsyncAt(x10_int id, x10aux::ref<x10::lang::VoidFun_0_0> body,
                           x10aux::ref<x10::lang::FinishState> finishState);
    static void runAsyncAt(x10_int id, x10aux::ref<x10::lang::VoidFun_0_0> body,
                           x10aux::ref<x10::lang::FinishState> finishState,
                           x10_int endpoint);
    static void event_probe();
    static x10_boolean FMGL(PRINT_STATS);
    
    static x10_boolean FMGL(PRINT_STATS__get)();
    static x10_long getAsyncsSent();
    static void setAsyncsSent(x10_long v);
    static x10_long getAsyncsReceived();
    static void setAsyncsReceived(x10_long v);
    static x10_long getSerializedBytes();
    static void setSerializedBytes(x10_long v);
    static x10_long getDeserializedBytes();
    static void setDeserializedBytes(x10_long v);
    template<class TPMGL(T)> static x10_long serializedSize(
      TPMGL(T) v);
    static x10::lang::Runtime__X10RTStats getX10RTStats();
    static x10::lang::Runtime__X10RTMessageStats getX10RTMessageStats(
      );
    static void deallocObject(x10aux::ref<x10::lang::Object> o);
    template<class TPMGL(T)> static void dealloc(x10aux::ref<x10::lang::Fun_0_0<TPMGL(T)> > o);
    static void dealloc(x10aux::ref<x10::lang::VoidFun_0_0> o);
    static x10_boolean x10_strict_finish();
    static x10_int x10_nthreads();
    static x10_int x10_max_threads();
    static x10_boolean x10_static_threads();
    static x10_boolean x10_warn_on_thread_creation();
    static x10aux::ref<x10::util::concurrent::Monitor> FMGL(staticMonitor);
    
    static x10aux::ref<x10::util::concurrent::Monitor> FMGL(staticMonitor__get)();
    static x10aux::ref<x10::util::HashMap<x10aux::ref<x10::lang::String>, x10aux::ref<x10::lang::String> > >
      FMGL(env);
    
    static x10aux::ref<x10::util::HashMap<x10aux::ref<x10::lang::String>, x10aux::ref<x10::lang::String> > >
      FMGL(env__get)();
    static x10_boolean FMGL(STRICT_FINISH);
    
    static x10_boolean FMGL(STRICT_FINISH__get)();
    static x10_int FMGL(NTHREADS);
    
    static x10_int FMGL(NTHREADS__get)();
    static x10_int FMGL(MAX_THREADS);
    
    static x10_int FMGL(MAX_THREADS__get)();
    static x10_boolean FMGL(STATIC_THREADS);
    
    static x10_boolean FMGL(STATIC_THREADS__get)();
    static x10_boolean FMGL(WARN_ON_THREAD_CREATION);
    
    static x10_boolean FMGL(WARN_ON_THREAD_CREATION__get)();
    static void wsInit();
    static x10aux::ref<x10::lang::Deque> wsFIFO();
    static void wsProcessEvents();
    static void wsRunAsync(x10_int id, x10aux::ref<x10::lang::VoidFun_0_0> body);
    static void wsRunCommand(x10_int id, x10aux::ref<x10::lang::VoidFun_0_0> body);
    static void wsBlock(x10aux::ref<x10::lang::Object> k);
    static void wsUnblock();
    static void wsEnd();
    static x10_boolean wsEnded();
    static x10aux::ref<x10::lang::Runtime__Pool> FMGL(pool);
    
    static x10aux::ref<x10::lang::Runtime__Pool> FMGL(pool__get)();
    static x10aux::ref<x10::util::concurrent::Monitor> FMGL(atomicMonitor);
    
    static x10aux::ref<x10::util::concurrent::Monitor> FMGL(atomicMonitor__get)();
    static x10aux::ref<x10::lang::FinishState__FinishStates>
      FMGL(finishStates);
    
    static x10aux::ref<x10::lang::FinishState__FinishStates>
      FMGL(finishStates__get)();
    static x10aux::ref<x10::lang::Runtime__Worker> worker(
      );
    static x10_int workerId();
    static x10_int poolSize();
    static x10aux::ref<x10::lang::Activity> activity();
    static x10::lang::Place home();
    static x10_int hereInt();
    static x10_int surplusActivityCount();
    static void start(x10aux::ref<x10::lang::VoidFun_0_0> init,
                      x10aux::ref<x10::lang::VoidFun_0_0> body);
    static void runAsync(x10::lang::Place place, x10aux::ref<x10::array::Array<x10aux::ref<x10::lang::Clock> > > clocks,
                         x10aux::ref<x10::lang::VoidFun_0_0> body);
    static void runAsync(x10::lang::Place place, x10aux::ref<x10::array::Array<x10aux::ref<x10::lang::Clock> > > clocks,
                         x10aux::ref<x10::lang::VoidFun_0_0> body,
                         x10_int endpoint);
    static void runAsync(x10::lang::Place place, x10aux::ref<x10::lang::VoidFun_0_0> body);
    static void runAsync(x10::lang::Place place, x10aux::ref<x10::lang::VoidFun_0_0> body,
                         x10_int endpoint);
    static void runAsync(x10aux::ref<x10::array::Array<x10aux::ref<x10::lang::Clock> > > clocks,
                         x10aux::ref<x10::lang::VoidFun_0_0> body);
    static void runAsync(x10aux::ref<x10::lang::VoidFun_0_0> body);
    static void runFinish(x10aux::ref<x10::lang::VoidFun_0_0> body);
    static void runUncountedAsync(x10::lang::Place place,
                                  x10aux::ref<x10::lang::VoidFun_0_0> body);
    static void runUncountedAsync(x10::lang::Place place,
                                  x10aux::ref<x10::lang::VoidFun_0_0> body,
                                  x10_int endpoint);
    static void runUncountedAsync(x10aux::ref<x10::lang::VoidFun_0_0> body);
    static void runAt(x10::lang::Place place, x10aux::ref<x10::lang::VoidFun_0_0> body);
    static void runAt(x10::lang::Place place, x10aux::ref<x10::lang::VoidFun_0_0> body,
                      x10_int endpoint);
    template<class TPMGL(T)> static TPMGL(T) evalAt(x10::lang::Place place,
                                                    x10aux::ref<x10::lang::Fun_0_0<TPMGL(T)> > eval);
    static void StaticInitBroadcastDispatcherLock();
    static void StaticInitBroadcastDispatcherAwait();
    static void StaticInitBroadcastDispatcherUnlock();
    static void StaticInitBroadcastDispatcherNotify();
    static void enterAtomic();
    static void ensureNotInAtomic();
    static void exitAtomic();
    static void exitWSWhen(x10_boolean b);
    static void awaitAtomic();
    static x10aux::ref<x10::lang::FinishState> startFinish(
      );
    static x10aux::ref<x10::lang::FinishState> startFinish(
      x10_int pragma);
    static x10aux::ref<x10::lang::FinishState> startLocalFinish(
      );
    static x10aux::ref<x10::lang::FinishState> startSimpleFinish(
      );
    static void stopFinish(x10aux::ref<x10::lang::FinishState> f);
    static void pushException(x10aux::ref<x10::lang::Throwable> t);
    template<class TPMGL(T)> static x10aux::ref<x10::lang::FinishState>
      startCollectingFinish(x10aux::ref<x10::lang::Reducible<TPMGL(T)> > r);
    template<class TPMGL(T)> static void makeOffer(TPMGL(T) t);
    template<class TPMGL(T)> static TPMGL(T) stopCollectingFinish(
      x10aux::ref<x10::lang::FinishState> f);
    static void execute(x10aux::ref<x10::lang::Activity> activity);
    static void execute(x10aux::ref<x10::lang::VoidFun_0_0> body,
                        x10aux::ref<x10::lang::FinishState> finishState);
    static void probe();
    static void increaseParallelism();
    static void decreaseParallelism(x10_int n);
    virtual x10aux::ref<x10::lang::Runtime> x10__lang__Runtime____x10__lang__Runtime__this(
      );
    void _constructor();
    
    static x10aux::ref<x10::lang::Runtime> _make();
    
    
    // Serialization
    public: static const x10aux::serialization_id_t _serialization_id;
    
    public: x10aux::serialization_id_t _get_serialization_id() {
         return _serialization_id;
    }
    
    public: virtual void _serialize_body(x10aux::serialization_buffer& buf);
    
    public: static x10aux::ref<x10::lang::Reference> _deserializer(x10aux::deserialization_buffer& buf);
    
    public: void _deserialize_body(x10aux::deserialization_buffer& buf);
    
};

} } 
#endif // X10_LANG_RUNTIME_H

namespace x10 { namespace lang { 
class Runtime;
} } 

#ifndef X10_LANG_RUNTIME_H_NODEPS
#define X10_LANG_RUNTIME_H_NODEPS
#include <x10/lang/Object.h>
#include <x10/lang/Any.h>
#include <x10/compiler/Native.h>
#include <x10/lang/String.h>
#include <x10/lang/Int.h>
#include <x10/lang/Boolean.h>
#include <x10/util/HashMap.h>
#include <x10/lang/VoidFun_0_0.h>
#include <x10/lang/FinishState.h>
#include <x10/lang/Long.h>
#include <x10/lang/Runtime__X10RTStats.h>
#include <x10/lang/Runtime__X10RTMessageStats.h>
#include <x10/lang/Fun_0_0.h>
#include <x10/util/NoSuchElementException.h>
#include <x10/lang/NumberFormatException.h>
#include <x10/util/concurrent/Monitor.h>
#include <x10/compiler/PerProcess.h>
#include <x10/lang/Runtime__Pool.h>
#include <x10/lang/Deque.h>
#include <x10/lang/Runtime__Worker.h>
#include <x10/lang/FinishState__FinishStates.h>
#include <x10/lang/Thread.h>
#include <x10/lang/Activity.h>
#include <x10/lang/Place.h>
#include <x10/lang/Throwable.h>
#include <x10/lang/FinishState__Finish.h>
#include <x10/lang/RuntimeException.h>
#include <x10/compiler/Finalization.h>
#include <x10/compiler/Abort.h>
#include <x10/compiler/CompilerFlags.h>
#include <x10/lang/FinishState__FinishSkeleton.h>
#include <x10/util/concurrent/SimpleLatch.h>
#include <x10/compiler/RemoteInvocation.h>
#include <x10/array/Array.h>
#include <x10/lang/Clock.h>
#include <x10/lang/Activity__ClockPhases.h>
#include <x10/lang/FinishState__UncountedFinish.h>
#include <x10/lang/Runtime__RemoteControl.h>
#include <x10/compiler/StackAllocate.h>
#include <x10/lang/GlobalRef.h>
#include <x10/compiler/AsyncClosure.h>
#include <x10/lang/Runtime__Remote.h>
#include <x10/util/Box.h>
#include <x10/util/concurrent/Lock.h>
#include <x10/compiler/Pragma.h>
#include <x10/lang/FinishState__FinishAsync.h>
#include <x10/lang/FinishState__FinishHere.h>
#include <x10/lang/FinishState__FinishSPMD.h>
#include <x10/lang/FinishState__LocalFinish.h>
#include <x10/lang/Reducible.h>
#include <x10/lang/FinishState__CollectingFinish.h>
#include <x10/compiler/Pinned.h>
#ifndef X10_LANG_RUNTIME__CLOSURE__9_CLOSURE
#define X10_LANG_RUNTIME__CLOSURE__9_CLOSURE
#include <x10/lang/Closure.h>
#include <x10/lang/VoidFun_0_0.h>
template<class TPMGL(T)> class x10_lang_Runtime__closure__9 : public x10::lang::Closure {
    public:
    
    static typename x10::lang::VoidFun_0_0::template itable <x10_lang_Runtime__closure__9<TPMGL(T) > > _itable;
    static x10aux::itable_entry _itables[2];
    
    virtual x10aux::itable_entry* _getITables() { return _itables; }
    
    // closure body
    void __apply() {
        
        //#line 985 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10LocalDecl_c
        x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > me2 = (box)->__apply();
        
        //#line 986 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10FieldAssign_c
        me2->FMGL(t) = x10::util::Box<TPMGL(T)>::_make(result);
        
        //#line 987 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10FieldAssign_c
        me2->FMGL(clockPhases) = clockPhases;
        
        //#line 988 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10Call_c
        me2->release();
    }
    
    // captured environment
    x10::lang::GlobalRef<x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > > box;
    TPMGL(T) result;
    x10aux::ref<x10::lang::Activity__ClockPhases> clockPhases;
    
    x10aux::serialization_id_t _get_serialization_id() {
        return _serialization_id;
    }
    
    void _serialize_body(x10aux::serialization_buffer &buf) {
        buf.write(this->box);
        buf.write(this->result);
        buf.write(this->clockPhases);
    }
    
    template<class __T> static x10aux::ref<__T> _deserialize(x10aux::deserialization_buffer &buf) {
        x10_lang_Runtime__closure__9<TPMGL(T) >* storage = x10aux::alloc<x10_lang_Runtime__closure__9<TPMGL(T) > >();
        buf.record_reference(x10aux::ref<x10_lang_Runtime__closure__9<TPMGL(T) > >(storage));
        x10::lang::GlobalRef<x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > > that_box = buf.read<x10::lang::GlobalRef<x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > > >();
        TPMGL(T) that_result = buf.read<TPMGL(T)>();
        x10aux::ref<x10::lang::Activity__ClockPhases> that_clockPhases = buf.read<x10aux::ref<x10::lang::Activity__ClockPhases> >();
        x10aux::ref<x10_lang_Runtime__closure__9<TPMGL(T) > > this_ = new (storage) x10_lang_Runtime__closure__9<TPMGL(T) >(that_box, that_result, that_clockPhases);
        return this_;
    }
    
    x10_lang_Runtime__closure__9(x10::lang::GlobalRef<x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > > box, TPMGL(T) result, x10aux::ref<x10::lang::Activity__ClockPhases> clockPhases) : box(box), result(result), clockPhases(clockPhases) { }
    
    static const x10aux::serialization_id_t _serialization_id;
    
    static const x10aux::RuntimeType* getRTT() { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    virtual const x10aux::RuntimeType *_type() const { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    
    x10aux::ref<x10::lang::String> toString() {
        return x10aux::string_utils::lit(this->toNativeString());
    }
    
    const char* toNativeString() {
        return "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10:984-989";
    }

};

template<class TPMGL(T)> typename x10::lang::VoidFun_0_0::template itable <x10_lang_Runtime__closure__9<TPMGL(T) > >x10_lang_Runtime__closure__9<TPMGL(T) >::_itable(&x10::lang::Reference::equals, &x10::lang::Closure::hashCode, &x10_lang_Runtime__closure__9<TPMGL(T) >::__apply, &x10_lang_Runtime__closure__9<TPMGL(T) >::toString, &x10::lang::Closure::typeName);
template<class TPMGL(T)> x10aux::itable_entry x10_lang_Runtime__closure__9<TPMGL(T) >::_itables[2] = {x10aux::itable_entry(&x10aux::getRTT<x10::lang::VoidFun_0_0>, &x10_lang_Runtime__closure__9<TPMGL(T) >::_itable),x10aux::itable_entry(NULL, NULL)};

template<class TPMGL(T)> const x10aux::serialization_id_t x10_lang_Runtime__closure__9<TPMGL(T) >::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10_lang_Runtime__closure__9<TPMGL(T) >::template _deserialize<x10::lang::Reference>,x10aux::CLOSURE_KIND_SIMPLE_ASYNC);

#endif // X10_LANG_RUNTIME__CLOSURE__9_CLOSURE
#ifndef X10_LANG_RUNTIME__CLOSURE__10_CLOSURE
#define X10_LANG_RUNTIME__CLOSURE__10_CLOSURE
#include <x10/lang/Closure.h>
#include <x10/lang/VoidFun_0_0.h>
template<class TPMGL(T)> class x10_lang_Runtime__closure__10 : public x10::lang::Closure {
    public:
    
    static typename x10::lang::VoidFun_0_0::template itable <x10_lang_Runtime__closure__10<TPMGL(T) > > _itable;
    static x10aux::itable_entry _itables[2];
    
    virtual x10aux::itable_entry* _getITables() { return _itables; }
    
    // closure body
    void __apply() {
        
        //#line 992 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10LocalDecl_c
        x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > me2 = (box)->__apply();
        
        //#line 993 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10FieldAssign_c
        me2->FMGL(e) = e;
        
        //#line 994 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10FieldAssign_c
        me2->FMGL(clockPhases) = clockPhases;
        
        //#line 995 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10Call_c
        me2->release();
    }
    
    // captured environment
    x10::lang::GlobalRef<x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > > box;
    x10aux::ref<x10::lang::Throwable> e;
    x10aux::ref<x10::lang::Activity__ClockPhases> clockPhases;
    
    x10aux::serialization_id_t _get_serialization_id() {
        return _serialization_id;
    }
    
    void _serialize_body(x10aux::serialization_buffer &buf) {
        buf.write(this->box);
        buf.write(this->e);
        buf.write(this->clockPhases);
    }
    
    template<class __T> static x10aux::ref<__T> _deserialize(x10aux::deserialization_buffer &buf) {
        x10_lang_Runtime__closure__10<TPMGL(T) >* storage = x10aux::alloc<x10_lang_Runtime__closure__10<TPMGL(T) > >();
        buf.record_reference(x10aux::ref<x10_lang_Runtime__closure__10<TPMGL(T) > >(storage));
        x10::lang::GlobalRef<x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > > that_box = buf.read<x10::lang::GlobalRef<x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > > >();
        x10aux::ref<x10::lang::Throwable> that_e = buf.read<x10aux::ref<x10::lang::Throwable> >();
        x10aux::ref<x10::lang::Activity__ClockPhases> that_clockPhases = buf.read<x10aux::ref<x10::lang::Activity__ClockPhases> >();
        x10aux::ref<x10_lang_Runtime__closure__10<TPMGL(T) > > this_ = new (storage) x10_lang_Runtime__closure__10<TPMGL(T) >(that_box, that_e, that_clockPhases);
        return this_;
    }
    
    x10_lang_Runtime__closure__10(x10::lang::GlobalRef<x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > > box, x10aux::ref<x10::lang::Throwable> e, x10aux::ref<x10::lang::Activity__ClockPhases> clockPhases) : box(box), e(e), clockPhases(clockPhases) { }
    
    static const x10aux::serialization_id_t _serialization_id;
    
    static const x10aux::RuntimeType* getRTT() { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    virtual const x10aux::RuntimeType *_type() const { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    
    x10aux::ref<x10::lang::String> toString() {
        return x10aux::string_utils::lit(this->toNativeString());
    }
    
    const char* toNativeString() {
        return "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10:991-996";
    }

};

template<class TPMGL(T)> typename x10::lang::VoidFun_0_0::template itable <x10_lang_Runtime__closure__10<TPMGL(T) > >x10_lang_Runtime__closure__10<TPMGL(T) >::_itable(&x10::lang::Reference::equals, &x10::lang::Closure::hashCode, &x10_lang_Runtime__closure__10<TPMGL(T) >::__apply, &x10_lang_Runtime__closure__10<TPMGL(T) >::toString, &x10::lang::Closure::typeName);
template<class TPMGL(T)> x10aux::itable_entry x10_lang_Runtime__closure__10<TPMGL(T) >::_itables[2] = {x10aux::itable_entry(&x10aux::getRTT<x10::lang::VoidFun_0_0>, &x10_lang_Runtime__closure__10<TPMGL(T) >::_itable),x10aux::itable_entry(NULL, NULL)};

template<class TPMGL(T)> const x10aux::serialization_id_t x10_lang_Runtime__closure__10<TPMGL(T) >::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10_lang_Runtime__closure__10<TPMGL(T) >::template _deserialize<x10::lang::Reference>,x10aux::CLOSURE_KIND_SIMPLE_ASYNC);

#endif // X10_LANG_RUNTIME__CLOSURE__10_CLOSURE
#ifndef X10_LANG_RUNTIME__CLOSURE__8_CLOSURE
#define X10_LANG_RUNTIME__CLOSURE__8_CLOSURE
#include <x10/lang/Closure.h>
#include <x10/lang/VoidFun_0_0.h>
template<class TPMGL(T)> class x10_lang_Runtime__closure__8 : public x10::lang::Closure {
    public:
    
    static typename x10::lang::VoidFun_0_0::template itable <x10_lang_Runtime__closure__8<TPMGL(T) > > _itable;
    static x10aux::itable_entry _itables[2];
    
    virtual x10aux::itable_entry* _getITables() { return _itables; }
    
    // closure body
    void __apply() {
        
        //#line 981 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10FieldAssign_c
        x10aux::nullCheck(x10::lang::Runtime::activity())->FMGL(clockPhases) =
          clockPhases;
        
        //#line 982 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": polyglot.ast.Try_c
        try {
            
            //#line 983 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10LocalDecl_c
            TPMGL(T) result = x10::lang::Fun_0_0<TPMGL(T)>::__apply(x10aux::nullCheck(eval));
            
            //#line 984 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10Call_c
            x10::lang::Runtime::runAsync(x10::lang::Place::place((box)->location),
                                         x10aux::ref<x10::lang::VoidFun_0_0>(x10aux::ref<x10_lang_Runtime__closure__9<TPMGL(T) > >(new (x10aux::alloc<x10::lang::VoidFun_0_0>(sizeof(x10_lang_Runtime__closure__9<TPMGL(T)>)))x10_lang_Runtime__closure__9<TPMGL(T)>(box, result, clockPhases))));
        }
        catch (x10aux::__ref& __ref__1474) {
            x10aux::ref<x10::lang::Throwable>& __exc__ref__1474 = (x10aux::ref<x10::lang::Throwable>&)__ref__1474;
            if (true) {
                x10aux::ref<x10::lang::Throwable> e = static_cast<x10aux::ref<x10::lang::Throwable> >(__exc__ref__1474);
                {
                    
                    //#line 991 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10Call_c
                    x10::lang::Runtime::runAsync(x10::lang::Place::place((box)->location),
                                                 x10aux::ref<x10::lang::VoidFun_0_0>(x10aux::ref<x10_lang_Runtime__closure__10<TPMGL(T) > >(new (x10aux::alloc<x10::lang::VoidFun_0_0>(sizeof(x10_lang_Runtime__closure__10<TPMGL(T)>)))x10_lang_Runtime__closure__10<TPMGL(T)>(box, e, clockPhases))));
                }
            } else
            throw;
        }
        
        //#line 998 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10FieldAssign_c
        x10aux::nullCheck(x10::lang::Runtime::activity())->
          FMGL(clockPhases) = X10_NULL;
    }
    
    // captured environment
    x10aux::ref<x10::lang::Activity__ClockPhases> clockPhases;
    x10aux::ref<x10::lang::Fun_0_0<TPMGL(T)> > eval;
    x10::lang::GlobalRef<x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > > box;
    
    x10aux::serialization_id_t _get_serialization_id() {
        return _serialization_id;
    }
    
    void _serialize_body(x10aux::serialization_buffer &buf) {
        buf.write(this->clockPhases);
        buf.write(this->eval);
        buf.write(this->box);
    }
    
    template<class __T> static x10aux::ref<__T> _deserialize(x10aux::deserialization_buffer &buf) {
        x10_lang_Runtime__closure__8<TPMGL(T) >* storage = x10aux::alloc<x10_lang_Runtime__closure__8<TPMGL(T) > >();
        buf.record_reference(x10aux::ref<x10_lang_Runtime__closure__8<TPMGL(T) > >(storage));
        x10aux::ref<x10::lang::Activity__ClockPhases> that_clockPhases = buf.read<x10aux::ref<x10::lang::Activity__ClockPhases> >();
        x10aux::ref<x10::lang::Fun_0_0<TPMGL(T)> > that_eval = buf.read<x10aux::ref<x10::lang::Fun_0_0<TPMGL(T)> > >();
        x10::lang::GlobalRef<x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > > that_box = buf.read<x10::lang::GlobalRef<x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > > >();
        x10aux::ref<x10_lang_Runtime__closure__8<TPMGL(T) > > this_ = new (storage) x10_lang_Runtime__closure__8<TPMGL(T) >(that_clockPhases, that_eval, that_box);
        return this_;
    }
    
    x10_lang_Runtime__closure__8(x10aux::ref<x10::lang::Activity__ClockPhases> clockPhases, x10aux::ref<x10::lang::Fun_0_0<TPMGL(T)> > eval, x10::lang::GlobalRef<x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > > box) : clockPhases(clockPhases), eval(eval), box(box) { }
    
    static const x10aux::serialization_id_t _serialization_id;
    
    static const x10aux::RuntimeType* getRTT() { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    virtual const x10aux::RuntimeType *_type() const { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    
    x10aux::ref<x10::lang::String> toString() {
        return x10aux::string_utils::lit(this->toNativeString());
    }
    
    const char* toNativeString() {
        return "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10:980-999";
    }

};

template<class TPMGL(T)> typename x10::lang::VoidFun_0_0::template itable <x10_lang_Runtime__closure__8<TPMGL(T) > >x10_lang_Runtime__closure__8<TPMGL(T) >::_itable(&x10::lang::Reference::equals, &x10::lang::Closure::hashCode, &x10_lang_Runtime__closure__8<TPMGL(T) >::__apply, &x10_lang_Runtime__closure__8<TPMGL(T) >::toString, &x10::lang::Closure::typeName);
template<class TPMGL(T)> x10aux::itable_entry x10_lang_Runtime__closure__8<TPMGL(T) >::_itables[2] = {x10aux::itable_entry(&x10aux::getRTT<x10::lang::VoidFun_0_0>, &x10_lang_Runtime__closure__8<TPMGL(T) >::_itable),x10aux::itable_entry(NULL, NULL)};

template<class TPMGL(T)> const x10aux::serialization_id_t x10_lang_Runtime__closure__8<TPMGL(T) >::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10_lang_Runtime__closure__8<TPMGL(T) >::template _deserialize<x10::lang::Reference>,x10aux::CLOSURE_KIND_SIMPLE_ASYNC);

#endif // X10_LANG_RUNTIME__CLOSURE__8_CLOSURE
#ifndef X10_LANG_RUNTIME_H_GENERICS
#define X10_LANG_RUNTIME_H_GENERICS
inline x10_int x10::lang::Runtime::FMGL(PLATFORM_MAX_THREADS__get)() {
    if (FMGL(PLATFORM_MAX_THREADS__status) != x10aux::INITIALIZED) {
        FMGL(PLATFORM_MAX_THREADS__init)();
    }
    return x10::lang::Runtime::FMGL(PLATFORM_MAX_THREADS);
}

inline x10_boolean x10::lang::Runtime::FMGL(DEFAULT_STATIC_THREADS__get)() {
    return x10::lang::Runtime::FMGL(DEFAULT_STATIC_THREADS);
}

inline x10_boolean x10::lang::Runtime::FMGL(PRINT_STATS__get)() {
    return x10::lang::Runtime::FMGL(PRINT_STATS);
}

#ifndef X10_LANG_RUNTIME_H_serializedSize_1419
#define X10_LANG_RUNTIME_H_serializedSize_1419
template<class TPMGL(T)> x10_long x10::lang::Runtime::serializedSize(TPMGL(T) v) {
    
    //#line 149 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10LocalDecl_c
    x10_long r;
    x10aux::serialization_buffer buf; buf.write(v); r = buf.length();
    
    //#line 153 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10Return_c
    return r;
    
}
#endif // X10_LANG_RUNTIME_H_serializedSize_1419
#ifndef X10_LANG_RUNTIME_H_dealloc_1423
#define X10_LANG_RUNTIME_H_dealloc_1423
template<class TPMGL(T)> void x10::lang::Runtime::dealloc(x10aux::ref<x10::lang::Fun_0_0<TPMGL(T)> > o) {
 
}
#endif // X10_LANG_RUNTIME_H_dealloc_1423
inline x10aux::ref<x10::util::concurrent::Monitor> x10::lang::Runtime::FMGL(staticMonitor__get)() {
    return x10::lang::Runtime::FMGL(staticMonitor);
}

inline x10aux::ref<x10::util::HashMap<x10aux::ref<x10::lang::String>, x10aux::ref<x10::lang::String> > >
  x10::lang::Runtime::FMGL(env__get)() {
    return x10::lang::Runtime::FMGL(env);
}

inline x10_boolean x10::lang::Runtime::FMGL(STRICT_FINISH__get)() {
    return x10::lang::Runtime::FMGL(STRICT_FINISH);
}

inline x10_int x10::lang::Runtime::FMGL(NTHREADS__get)() {
    return x10::lang::Runtime::FMGL(NTHREADS);
}

inline x10_int x10::lang::Runtime::FMGL(MAX_THREADS__get)() {
    return x10::lang::Runtime::FMGL(MAX_THREADS);
}

inline x10_boolean x10::lang::Runtime::FMGL(STATIC_THREADS__get)() {
    return x10::lang::Runtime::FMGL(STATIC_THREADS);
}

inline x10_boolean x10::lang::Runtime::FMGL(WARN_ON_THREAD_CREATION__get)() {
    return x10::lang::Runtime::FMGL(WARN_ON_THREAD_CREATION);
}

inline x10aux::ref<x10::lang::Runtime__Pool> x10::lang::Runtime::FMGL(pool__get)() {
    return x10::lang::Runtime::FMGL(pool);
}

inline x10aux::ref<x10::util::concurrent::Monitor> x10::lang::Runtime::FMGL(atomicMonitor__get)() {
    return x10::lang::Runtime::FMGL(atomicMonitor);
}

inline x10aux::ref<x10::lang::FinishState__FinishStates> x10::lang::Runtime::FMGL(finishStates__get)() {
    return x10::lang::Runtime::FMGL(finishStates);
}

#ifndef X10_LANG_RUNTIME_H_evalAt_1472
#define X10_LANG_RUNTIME_H_evalAt_1472
template<class TPMGL(T)> TPMGL(T) x10::lang::Runtime::evalAt(x10::lang::Place place,
                                                             x10aux::ref<x10::lang::Fun_0_0<TPMGL(T)> > eval) {
    
    //#line 969 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10Call_c
    x10::lang::Runtime::ensureNotInAtomic();
    
    //#line 970 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10If_c
    if ((x10aux::struct_equals(place->FMGL(id), x10aux::here)))
    {
        
        //#line 971 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": polyglot.ast.Try_c
        try {
            
            //#line 972 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10Return_c
            return x10aux::deep_copy<TPMGL(T) >(x10::lang::Fun_0_0<TPMGL(T)>::__apply(x10aux::nullCheck(x10aux::deep_copy<x10aux::ref<x10::lang::Fun_0_0<TPMGL(T)> > >(eval))));
            
        }
        catch (x10aux::__ref& __ref__1473) {
            x10aux::ref<x10::lang::Throwable>& __exc__ref__1473 = (x10aux::ref<x10::lang::Throwable>&)__ref__1473;
            if (true) {
                x10aux::ref<x10::lang::Throwable> t = static_cast<x10aux::ref<x10::lang::Throwable> >(__exc__ref__1473);
                {
                    
                    //#line 974 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": polyglot.ast.Throw_c
                    x10aux::throwException(x10aux::nullCheck(x10aux::deep_copy<x10aux::ref<x10::lang::Throwable> >(t)));
                }
            } else
            throw;
        }
    }
    
    //#line 977 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10LocalDecl_c
    x10::lang::Runtime__Remote<TPMGL(T)> _StackAllocate_me;
     _StackAllocate_me._constructor();
    x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > me(&_StackAllocate_me);
    
    //#line 978 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10LocalDecl_c
    x10::lang::GlobalRef<x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > > box =
      x10::lang::GlobalRef<x10aux::ref<x10::lang::Runtime__Remote<TPMGL(T)> > >::_make(me);
    
    //#line 979 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10LocalDecl_c
    x10aux::ref<x10::lang::Activity__ClockPhases> clockPhases =
      x10aux::nullCheck(x10::lang::Runtime::activity())->
        FMGL(clockPhases);
    
    //#line 980 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10Call_c
    x10::lang::Runtime::runAsync(place, x10aux::ref<x10::lang::VoidFun_0_0>(x10aux::ref<x10_lang_Runtime__closure__8<TPMGL(T) > >(new (x10aux::alloc<x10::lang::VoidFun_0_0>(sizeof(x10_lang_Runtime__closure__8<TPMGL(T)>)))x10_lang_Runtime__closure__8<TPMGL(T)>(clockPhases, eval, box))));
    
    //#line 1000 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10Call_c
    me->await();
    
    //#line 1001 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10Call_c
    x10aux::dealloc(eval.operator->());
    
    //#line 1002 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10FieldAssign_c
    x10aux::nullCheck(x10::lang::Runtime::activity())->FMGL(clockPhases) =
      me->FMGL(clockPhases);
    
    //#line 1003 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10If_c
    if ((!x10aux::struct_equals(X10_NULL, me->FMGL(e)))) {
        
        //#line 1004 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": polyglot.ast.Throw_c
        x10aux::throwException(x10aux::nullCheck(me->FMGL(e)));
    }
    
    //#line 1006 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10Return_c
    return x10aux::nullCheck(me->FMGL(t))->FMGL(value);
    
}
#endif // X10_LANG_RUNTIME_H_evalAt_1472
#ifndef X10_LANG_RUNTIME_H_startCollectingFinish_1490
#define X10_LANG_RUNTIME_H_startCollectingFinish_1490
template<class TPMGL(T)> x10aux::ref<x10::lang::FinishState>
  x10::lang::Runtime::startCollectingFinish(x10aux::ref<x10::lang::Reducible<TPMGL(T)> > r) {
    
    //#line 1122 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10Return_c
    return x10aux::nullCheck(x10::lang::Runtime::activity())->swapFinish(
             x10aux::class_cast_unchecked<x10aux::ref<x10::lang::FinishState> >(x10::lang::FinishState__CollectingFinish<TPMGL(T)>::_make(r)));
    
}
#endif // X10_LANG_RUNTIME_H_startCollectingFinish_1490
#ifndef X10_LANG_RUNTIME_H_makeOffer_1491
#define X10_LANG_RUNTIME_H_makeOffer_1491
template<class TPMGL(T)> void x10::lang::Runtime::makeOffer(
  TPMGL(T) t) {
    
    //#line 1126 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10LocalDecl_c
    x10aux::ref<x10::lang::FinishState> state = x10aux::nullCheck(x10::lang::Runtime::activity())->finishState();
    
    //#line 1128 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": Eval of x10.ast.X10Call_c
    x10aux::nullCheck((x10aux::class_cast<x10aux::ref<x10::lang::FinishState__CollectingFinish<TPMGL(T)> > >(state)))->accept(
      t, x10::lang::Runtime::workerId());
}
#endif // X10_LANG_RUNTIME_H_makeOffer_1491
#ifndef X10_LANG_RUNTIME_H_stopCollectingFinish_1492
#define X10_LANG_RUNTIME_H_stopCollectingFinish_1492
template<class TPMGL(T)> TPMGL(T) x10::lang::Runtime::stopCollectingFinish(
  x10aux::ref<x10::lang::FinishState> f) {
    
    //#line 1132 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10LocalDecl_c
    x10aux::ref<x10::lang::FinishState> state = x10aux::nullCheck(x10::lang::Runtime::activity())->swapFinish(
                                                  f);
    
    //#line 1133 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/Runtime.x10": x10.ast.X10Return_c
    return x10aux::nullCheck((x10aux::class_cast<x10aux::ref<x10::lang::FinishState__CollectingFinish<TPMGL(T)> > >(state)))->waitForFinishExpr();
    
}
#endif // X10_LANG_RUNTIME_H_stopCollectingFinish_1492
#endif // X10_LANG_RUNTIME_H_GENERICS
#endif // __X10_LANG_RUNTIME_H_NODEPS
