#ifndef __X10_LANG_FINISHSTATE_H
#define __X10_LANG_FINISHSTATE_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 Place;
} } 
namespace x10 { namespace lang { 
class Throwable;
} } 
namespace x10 { namespace util { namespace concurrent { 
class SimpleLatch;
} } } 
namespace x10 { namespace lang { 
template<class TPMGL(T)> class GlobalRef;
} } 
namespace x10 { namespace lang { 
class Boolean;
} } 
namespace x10 { namespace lang { 
class Runtime;
} } 
namespace x10 { namespace compiler { 
class CompilerFlags;
} } 
namespace x10 { namespace lang { 
class FailedDynamicCheckException;
} } 
namespace x10 { namespace lang { 
class FinishState__UncountedFinish;
} } 
namespace x10 { namespace lang { 

class FinishState : public x10::lang::Object   {
    public:
    RTT_H_DECLS_CLASS
    
    virtual void notifySubActivitySpawn(x10::lang::Place place) = 0;
    virtual void notifyActivityCreation() = 0;
    virtual void notifyActivityTermination() = 0;
    virtual void pushException(x10aux::ref<x10::lang::Throwable> t) = 0;
    virtual void waitForFinish() = 0;
    virtual x10aux::ref<x10::util::concurrent::SimpleLatch> simpleLatch() = 0;
    template<class TPMGL(T)> static TPMGL(T) deref(x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > root);
    static x10aux::ref<x10::lang::FinishState__UncountedFinish> FMGL(UNCOUNTED_FINISH);
    
    static void FMGL(UNCOUNTED_FINISH__do_init)();
    static void FMGL(UNCOUNTED_FINISH__init)();
    static volatile x10aux::status FMGL(UNCOUNTED_FINISH__status);
    static x10aux::ref<x10::lang::FinishState__UncountedFinish> FMGL(UNCOUNTED_FINISH__get)();
    static x10aux::ref<x10::lang::Reference> FMGL(UNCOUNTED_FINISH__deserialize)(x10aux::deserialization_buffer &buf);
    static const x10aux::serialization_id_t FMGL(UNCOUNTED_FINISH__id);
    
    virtual x10aux::ref<x10::lang::FinishState> x10__lang__FinishState____x10__lang__FinishState__this(
      );
    void _constructor();
    
    
    // Serialization
    public: virtual void _serialize_body(x10aux::serialization_buffer& buf);
    
    public: void _deserialize_body(x10aux::deserialization_buffer& buf);
    
};

} } 
#endif // X10_LANG_FINISHSTATE_H

namespace x10 { namespace lang { 
class FinishState;
} } 

#ifndef X10_LANG_FINISHSTATE_H_NODEPS
#define X10_LANG_FINISHSTATE_H_NODEPS
#include <x10/lang/Object.h>
#include <x10/lang/Place.h>
#include <x10/lang/Throwable.h>
#include <x10/util/concurrent/SimpleLatch.h>
#include <x10/lang/GlobalRef.h>
#include <x10/lang/Boolean.h>
#include <x10/lang/Runtime.h>
#include <x10/compiler/CompilerFlags.h>
#include <x10/lang/FailedDynamicCheckException.h>
#include <x10/lang/FinishState__UncountedFinish.h>
#ifndef X10_LANG_FINISHSTATE_H_GENERICS
#define X10_LANG_FINISHSTATE_H_GENERICS
#ifndef X10_LANG_FINISHSTATE_H_deref_1137
#define X10_LANG_FINISHSTATE_H_deref_1137
template<class TPMGL(T)> TPMGL(T) x10::lang::FinishState::deref(x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > root) {
    
    //#line 36 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10Return_c
    return x10aux::class_cast<TPMGL(T)>(((__extension__ ({
        
        //#line 36 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10LocalDecl_c
        x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > __desugarer__var__57__43812 =
          root;
        
        //#line 36 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10LocalDecl_c
        x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ret43813;
        
        //#line 36 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10If_c
        if (!((x10aux::struct_equals(x10::lang::Place::place((__desugarer__var__57__43812)->location),
                                     x10::lang::Place::_make(x10aux::here)))))
        {
            
            //#line 36 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10If_c
            if (true) {
                
                //#line 36 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": polyglot.ast.Throw_c
                x10aux::throwException(x10aux::nullCheck(x10::lang::FailedDynamicCheckException::_make(x10aux::string_utils::lit("x10.lang.GlobalRef[x10.lang.FinishState]{self.home==here}"))));
            }
            
        }
        
        //#line 36 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10LocalAssign_c
        ret43813 = __desugarer__var__57__43812;
        ret43813;
    }))
    )->__apply());
    
}
#endif // X10_LANG_FINISHSTATE_H_deref_1137
inline x10aux::ref<x10::lang::FinishState__UncountedFinish>
  x10::lang::FinishState::FMGL(UNCOUNTED_FINISH__get)() {
    if (FMGL(UNCOUNTED_FINISH__status) != x10aux::INITIALIZED) {
        FMGL(UNCOUNTED_FINISH__init)();
    }
    return x10::lang::FinishState::FMGL(UNCOUNTED_FINISH);
}

#endif // X10_LANG_FINISHSTATE_H_GENERICS
#endif // __X10_LANG_FINISHSTATE_H_NODEPS
