Component& Component::managed(bool yes){ if(not managed()){ if(not yes) STENCILA_THROW(Exception,"It is only possible to turn on component management; use `manage(true)`."); repo(true); } return *this; }
bool Window::EmbeddedWindow::setWindow(Window* win) { if(!win) { warn() << "EmbeddedWindow [" << _name << "] attempted to set a NULL Window." << std::endl ; return false; } if (_window.valid() && _parent) unparented(_parent); _window = win; _window->resize(); _window->setVisibilityMode(VM_PARTIAL); if(_parent) parented(_parent); WindowManager* wm = _getWindowManager(); if(wm) managed(wm); return true; }
void Response::run(STATE) { size_t pending_requests = 0; char* request = NULL; Channel* inbox = inbox_.get(); Channel* outbox = outbox_.get(); String* response = 0; OnStack<3> os(state, inbox, outbox, response); while(!thread_exit_) { { utilities::thread::SpinLock::LockGuard guard(list_lock_); if(request_list_->size() > 0) { request = request_list_->back(); request_list_->pop_back(); } } if(thread_exit_) break; if(request) { ManagedPhase managed(state); pending_requests++; inbox->send(state, String::create(state, request)); request = NULL; } if(pending_requests > 0) { if((response = try_as<String>(outbox->try_receive(state)))) { write_response(state, reinterpret_cast<const char*>(response->byte_address()), response->byte_size()); pending_requests--; continue; } } { UnmanagedPhase unmanaged(state); utilities::thread::Mutex::LockGuard guard(response_lock_); if(thread_exit_) break; response_cond_.wait(response_lock_); } } }
void ExtensionFinalizer::finalize(STATE) { ManagedPhase managed(state); NativeMethodEnvironment* env = state->vm()->native_method_environment; NativeMethodFrame nmf(env, 0, 0); ExceptionPoint ep(env); CallFrame* previous_frame = 0; CallFrame* call_frame = ALLOCA_CALL_FRAME(0); call_frame->previous = NULL; call_frame->lexical_scope_ = 0; call_frame->dispatch_data = (void*)&nmf; call_frame->compiled_code = 0; call_frame->flags = CallFrame::cNativeMethod; call_frame->top_scope_ = 0; call_frame->scope = 0; call_frame->arguments = 0; env->set_current_call_frame(0); env->set_current_native_frame(&nmf); // Register the CallFrame, because we might GC below this. if(state->vm()->push_call_frame(state, call_frame, previous_frame)) { nmf.setup(Qnil, Qnil, Qnil, Qnil); PLACE_EXCEPTION_POINT(ep); if(unlikely(ep.jumped_to())) { logger::warn( "finalizer: an exception occurred running a NativeMethod finalizer"); } else { (*finalizer_)(state, object()); } state->vm()->pop_call_frame(state, previous_frame); env->set_current_call_frame(0); env->set_current_native_frame(0); } else { logger::warn("finalizer: stack error"); } }
void ManagedFinalizer::finalize(STATE) { ManagedPhase managed(state); /* Rubinius specific code. If the finalizer is cTrue, then send the * object the __finalize__ message. */ if(finalizer_->true_p()) { object()->send(state, state->symbol("__finalize__")); } else { Array* ary = Array::create(state, 1); ary->set(state, 0, object()->id(state)); if(!finalizer_->send(state, G(sym_call), ary)) { if(state->vm()->thread_state()->raise_reason() == cException) { logger::warn( "finalizer: an exception occurred running a Ruby finalizer: %s", state->vm()->thread_state()->current_exception()->message_c_str(state)); } } } }