void operator()(SharedState& shared_state, typename std::enable_if< traits::is_shared_state<SharedState>::value >::type* = nullptr) const { std::size_t counter = wait_.count_.load(boost::memory_order_seq_cst); if (counter < wait_.needed_count_ && !shared_state->is_ready()) { // handle future only if not enough futures are ready yet // also, do not touch any futures which are already ready shared_state->execute_deferred(); // execute_deferred might have made the future ready if (!shared_state->is_ready()) { shared_state->set_on_completed( util::deferred_call( &wait_some<Sequence>::on_future_ready, wait_.shared_from_this(), threads::get_self_id())); return; } } if (wait_.count_.fetch_add(1) + 1 == wait_.needed_count_) { wait_.goal_reached_on_calling_thread_ = true; } }
int main(int argc, char **argv) { JITCompiler compiler; VMManager * manager = new VMManager; SharedState * shared = manager->create_shared_state(); ConfigParser * config = new ConfigParser; shared->user_config = config; VM* state = shared->thread_nexus()->new_vm(); state->initialize(VM::default_bytes); state->boot(); state->global_lock().lock(); std::ifstream stream(argv[1]); if(!stream) { cout << "Can't open ' " << argv[1] << "'\n"; return 1; } CompiledFile* cf = CompiledFile::load(state, stream); if(cf->magic != "!RBIX") { cout << "Invalid file.\n"; } MachineCode* mcode = as<CompiledCode>(cf->body(state))->formalize(state, false); delete cf; compiler.compile(state, mcode); MachineMethod* mm = MachineMethod::create(state, mcode, compiler); mm->show(); return 0; }
void operator()(SharedState& shared_state) const { std::size_t counter = wait_.count_.load(boost::memory_order_acquire); if (counter < wait_.needed_count_ && !shared_state->is_ready()) { // handle future only if not enough futures are ready yet // also, do not touch any futures which are already ready shared_state->set_on_completed(Callback(callback_)); } else { ++wait_.count_; } }
void create() { config_parser = new ConfigParser; shared = new SharedState(0, config, *config_parser); VM* vm = shared->thread_nexus()->new_vm(shared); state = new State(vm); initialize_as_root(state); }
void operator()(SharedState& shared_state) const { std::size_t counter = wait_.count_.load(boost::memory_order_seq_cst); if (counter < wait_.needed_count_ && !shared_state->is_ready()) { // handle future only if not enough futures are ready yet // also, do not touch any futures which are already ready shared_state->execute_deferred(); // execute_deferred might have made the future ready if (!shared_state->is_ready()) { shared_state->set_on_completed(Callback(callback_)); return; } } if (wait_.count_.fetch_add(1) + 1 == wait_.needed_count_) { wait_.goal_reached_on_calling_thread_ = true; } }
VM::VM(uint32_t id, SharedState& shared, const char* name) : memory::ManagedThread(id, shared, memory::ManagedThread::eRuby, name) , call_frame_(NULL) , thread_nexus_(shared.thread_nexus()) , saved_call_site_information_(NULL) , fiber_stacks_(this, shared) , park_(new Park) , stack_start_(0) , stack_size_(0) , current_stack_start_(0) , current_stack_size_(0) , interrupt_with_signal_(false) , interrupt_by_kill_(false) , check_local_interrupts_(false) , thread_step_(false) , interrupt_lock_() , method_missing_reason_(eNone) , constant_missing_reason_(vFound) , zombie_(false) , main_thread_(false) , thread_phase_(ThreadNexus::cUnmanaged) , profile_interval_(0) , profile_counter_(0) , shared(shared) , waiting_channel_(this, nil<Channel>()) , interrupted_exception_(this, nil<Exception>()) , thread(this, nil<Thread>()) , current_fiber(this, nil<Fiber>()) , root_fiber(this, nil<Fiber>()) , waiting_object_(this, cNil) , profile_(this, nil<Tuple>()) , profile_sample_count_(0) , max_profile_entries_(15) , min_profile_call_count_(0) , native_method_environment(NULL) , custom_wakeup_(NULL) , custom_wakeup_data_(NULL) , thread_state_(this) { if(memory()) { local_slab_.refill(0, 0); } set_profile_interval(); allocation_tracking_ = shared.config.allocation_tracking; }
ManagedThread::ManagedThread(SharedState& ss, ManagedThread::Kind kind) : shared_(ss) , kind_(kind) , name_(kind == eRuby ? "<ruby>" : "<system>") , thread_id_(ss.new_thread_id()) {}
virtual void onClick() { dynamic_cast<Battle*>(resume.get()) -> Resume(); app->SetNextState(resume); }
// Trampoline to call scheduler_loop() static void* __thread_tramp__(void* arg) { SharedState* ss = static_cast<SharedState*>(arg); ss->scheduler_loop(); return NULL; }