void release_test() { sig_type sig; bs2::connection conn; { bs2::scoped_connection scoped(sig.connect(&myslot)); BOOST_CHECK(scoped.connected()); conn = scoped.release(); } BOOST_CHECK(conn.connected()); bs2::connection conn2; { bs2::scoped_connection scoped(conn); BOOST_CHECK(scoped.connected()); conn = scoped.release(); BOOST_CHECK(conn.connected()); BOOST_CHECK(scoped.connected() == false); conn.disconnect(); // earlier release shouldn't affect new connection conn2 = sig.connect(&myslot); scoped = conn2; } BOOST_CHECK(conn2.connected() == false); }
void EXTDisjointTimerQuery::beginQueryEXT(GLenum target, WebGLTimerQueryEXT* query) { WebGLExtensionScopedContext scoped(this); if (scoped.isLost()) return; if (!query || query->isDeleted() || !query->validate(0, scoped.context())) { scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); return; } if (target != GL_TIME_ELAPSED_EXT) { scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); return; } if (m_currentElapsedQuery.get()) { scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); return; } if (query->hasTarget() && query->target() != target) { scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); return; } scoped.context()->webContext()->beginQueryEXT(target, query->object()); query->setTarget(target); m_currentElapsedQuery = query; }
void HttpLoader::threadHttpRequest() { try { base::ScopedValue<bool> scoped(m_done, false, true); LOG("Sending http request to %s...\n", m_url.c_str()); std::string dir = base::join_path(base::get_temp_path(), PACKAGE); base::make_all_directories(dir); std::string fn = m_url; base::replace_string(fn, ":", "-"); base::replace_string(fn, "/", "-"); base::replace_string(fn, "?", "-"); base::replace_string(fn, "&", "-"); fn = base::join_path(dir, fn); std::ofstream output(FSTREAM_PATH(fn), std::ofstream::binary); net::HttpRequest http(m_url); net::HttpResponse response(&output); http.send(response); if (response.status() == 200) m_filename = fn; LOG("Response: %d\n", response.status()); } catch (const std::exception& e) { LOG("Unexpected exception sending http request: '%s'\n", e.what()); } catch (...) { LOG("Unexpected unknown exception sending http request\n"); } }
void WebGLDrawBuffers::drawBuffersWEBGL(const Vector<GLenum>& buffers) { WebGLExtensionScopedContext scoped(this); if (scoped.isLost()) return; GLsizei n = buffers.size(); const GLenum* bufs = buffers.data(); if (!scoped.context()->m_framebufferBinding) { if (n != 1) { scoped.context()->synthesizeGLError(GL_INVALID_VALUE, "drawBuffersWEBGL", "more than one buffer"); return; } if (bufs[0] != GL_BACK && bufs[0] != GL_NONE) { scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "drawBuffersWEBGL", "BACK or NONE"); return; } // Because the backbuffer is simulated on all current WebKit ports, we need to change BACK to COLOR_ATTACHMENT0. GLenum value = (bufs[0] == GL_BACK) ? GL_COLOR_ATTACHMENT0 : GL_NONE; scoped.context()->webContext()->drawBuffersEXT(1, &value); scoped.context()->setBackDrawBuffer(bufs[0]); } else { if (n > scoped.context()->maxDrawBuffers()) { scoped.context()->synthesizeGLError(GL_INVALID_VALUE, "drawBuffersWEBGL", "more than max draw buffers"); return; } for (GLsizei i = 0; i < n; ++i) { if (bufs[i] != GL_NONE && bufs[i] != static_cast<GLenum>(GL_COLOR_ATTACHMENT0_EXT + i)) { scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "drawBuffersWEBGL", "COLOR_ATTACHMENTi_EXT or NONE"); return; } } scoped.context()->m_framebufferBinding->drawBuffers(buffers); } }
ScriptValue EXTDisjointTimerQuery::getQueryEXT(ScriptState* scriptState, GLenum target, GLenum pname) { WebGLExtensionScopedContext scoped(this); if (scoped.isLost()) return ScriptValue::createNull(scriptState); if (target == GL_TIMESTAMP_EXT || target == GL_TIME_ELAPSED_EXT) { switch (pname) { case GL_CURRENT_QUERY_EXT: if (GL_TIME_ELAPSED_EXT == target && m_currentElapsedQuery.get()) return WebGLAny(scriptState, m_currentElapsedQuery.get()); return ScriptValue::createNull(scriptState); case GL_QUERY_COUNTER_BITS_EXT: { GLint value = 0; scoped.context()->webContext()->getQueryivEXT(target, pname, &value); return WebGLAny(scriptState, value); } default: break; } } scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); return ScriptValue::createNull(scriptState); }
void Searcher::publishCharacters(const std::vector<Filesystem::AbsolutePath> & files){ PaintownUtil::Thread::ScopedLock scoped(subscriptionLock); for (vector<Subscriber*>::iterator it = subscriptions.begin(); it != subscriptions.end(); it++){ Subscriber * who = *it; who->receiveCharacters(files); } }
void FailPoint::setMode(Mode mode, ValType val, const BSONObj& extra) { /** * Outline: * * 1. Deactivates fail point to enter write-only mode * 2. Waits for all current readers of the fail point to finish * 3. Sets the new mode. */ scoped_lock scoped(_modMutex); // Step 1 disableFailPoint(); // Step 2 while (_fpInfo.load() != 0) { sleepmillis(50); } // Step 3 uassert(16442, stream() << "mode not supported " << static_cast<int>(mode), mode >= off && mode < numModes); _mode = mode; _timesOrPeriod.store(val); _data = extra.copy(); if (_mode != off) { enableFailPoint(); } }
void FailPoint::setMode(Mode mode, ValType val, const BSONObj& extra) { /** * Outline: * * 1. Deactivates fail point to enter write-only mode * 2. Waits for all current readers of the fail point to finish * 3. Sets the new mode. */ stdx::lock_guard<stdx::mutex> scoped(_modMutex); // Step 1 disableFailPoint(); // Step 2 while (_fpInfo.load() != 0) { sleepmillis(50); } _mode = mode; _timesOrPeriod.store(val); _data = extra.copy(); if (_mode != off) { enableFailPoint(); } }
ScriptValue EXTDisjointTimerQuery::getQueryObjectEXT(ScriptState* scriptState, WebGLTimerQueryEXT* query, GLenum pname) { WebGLExtensionScopedContext scoped(this); if (scoped.isLost()) return ScriptValue::createNull(scriptState); if (!query || query->isDeleted() || !query->validate(0, scoped.context()) || m_currentElapsedQuery == query) { scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); return ScriptValue::createNull(scriptState); } switch (pname) { case GL_QUERY_RESULT_EXT: { query->updateCachedResult(scoped.context()->webContext()); return WebGLAny(scriptState, query->getQueryResult()); } case GL_QUERY_RESULT_AVAILABLE_EXT: { query->updateCachedResult(scoped.context()->webContext()); return WebGLAny(scriptState, query->isQueryResultAvailable()); } default: scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); break; } return ScriptValue::createNull(scriptState); }
void EXTDisjointTimerQuery::queryCounterEXT(WebGLTimerQueryEXT* query, GLenum target) { WebGLExtensionScopedContext scoped(this); if (scoped.isLost()) return; if (!query || query->isDeleted() || !query->validate(0, scoped.context())) { scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); return; } if (target != GL_TIMESTAMP_EXT) { scoped.context()->webContext()->synthesizeGLError(GL_INVALID_ENUM); return; } if (query->hasTarget() && query->target() != target) { scoped.context()->webContext()->synthesizeGLError(GL_INVALID_OPERATION); return; } scoped.context()->webContext()->queryCounterEXT(query->object(), target); query->setTarget(target); query->resetCachedResult(); }
void EXTDisjointTimerQuery::queryCounterEXT(WebGLTimerQueryEXT* query, GLenum target) { WebGLExtensionScopedContext scoped(this); if (scoped.isLost()) return; if (!query || query->isDeleted() || !query->validate(0, scoped.context())) { scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "queryCounterEXT", "invalid query"); return; } if (target != GL_TIMESTAMP_EXT) { scoped.context()->synthesizeGLError(GL_INVALID_ENUM, "queryCounterEXT", "invalid target"); return; } if (query->hasTarget() && query->target() != target) { scoped.context()->synthesizeGLError(GL_INVALID_OPERATION, "queryCounterEXT", "target does not match query"); return; } // Timestamps are disabled in WebGL due to lack of driver support on multiple platforms, so we don't actually perform a GL call query->setTarget(target); query->resetCachedResult(); }
void Statistic::finished(shared_ptr<Statistic::JobMeasurement>& job) { #ifdef Statistic_Activated avgLock.lock(); uint32_t n; for(int c = 0; c < Component::Size; c++) { if (!job->stopped[c]) continue; AvgMeasurement& m = componentAvgs[c]; n = m.count[job->zoom]; m.average[job->zoom] *= n/(float)(n + 1.0f); m.average[job->zoom] += job->getDuration(c).total_microseconds() / (float)(n + 1.0f); m.count[job->zoom]++; } avgLock.unlock(); if (!config->has(opt::server::performance_log)) return; boost::mutex::scoped_lock scoped(bufferLock); measurementsBuffer.push_back(job); if(measurementsBuffer.size() > 100) { writeToFile(config->get<string>(opt::server::performance_log).c_str()); measurementsBuffer.clear(); } #endif }
/// called directly by dds_visitor::visit_structure() if -Wb,java void generate(UTL_ScopedName* name) { if (idl_global->is_dcps_type(name) == 0) { // no #pragma DCPS_DATA_TYPE, so nothing to generate return; } ACE_CString output_file = be_global->java_arg(); if (output_file.length()) { be_global->impl_name_ = output_file; } be_global->add_include("idl2jni_jni.h", BE_GlobalData::STREAM_CPP); std::string type = scoped(name); std::string file, jniclass, jpackage; for (UTL_ScopedName* sn = name; sn; sn = static_cast<UTL_ScopedName*>(sn->tail())) { std::string tmp = sn->head()->get_string(); if (tmp != "" && sn->tail()) { jpackage += tmp; file += tmp; ACE_OS::mkdir(file.c_str()); } for (size_t i = tmp.find('_'); i < tmp.length(); i = tmp.find('_', i + 1)) { tmp.insert(++i, 1, '1'); } jniclass += tmp; if (jniclass != "" && sn->tail()) { jniclass += '_'; jpackage += '.'; file += '/'; } } if (jpackage[jpackage.size() - 1] == '.') { jpackage.resize(jpackage.size() - 1); } std::string clazz = name->last_component()->get_string(); file += clazz + "TypeSupportImpl.java"; std::ofstream java(file.c_str()); java << (jpackage.size() ? "package " : "") << jpackage << (jpackage.size() ? ";\n" :"") << "public class " << clazz << "TypeSupportImpl extends _" << clazz << "TypeSupportTAOPeer {\n" " public " << clazz << "TypeSupportImpl() {\n" " super(_jni_init());\n" " }\n" " private static native long _jni_init();\n" "}\n"; be_global->impl_ << "extern \"C\" JNIEXPORT jlong JNICALL\n" "Java_" << jniclass << "TypeSupportImpl__1jni_1init(JNIEnv*, jclass) {\n" " return reinterpret_cast<jlong>(static_cast<CORBA::Object_ptr>(new " << type << "TypeSupportImpl));\n" "}\n\n"; }
void ANGLEInstancedArrays::drawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) { WebGLExtensionScopedContext scoped(this); if (scoped.isLost()) return; scoped.context()->drawArraysInstancedANGLE(mode, first, count, primcount); }
void ANGLEInstancedArrays::drawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, long long offset, GLsizei primcount) { WebGLExtensionScopedContext scoped(this); if (scoped.isLost()) return; scoped.context()->drawElementsInstancedANGLE(mode, count, type, offset, primcount); }
void connect_from_non_main_thread() { std::cout<<"main thread : "<<boost::this_thread::get_id()<<std::endl; boost::strict_scoped_thread<> scoped(boost::thread( boost::bind(&worker_thread2)) ); }
void ANGLEInstancedArrays::vertexAttribDivisorANGLE(GLuint index, GLuint divisor) { WebGLExtensionScopedContext scoped(this); if (scoped.isLost()) return; scoped.context()->vertexAttribDivisorANGLE(index, divisor); }
/* check for an in-memory copy of the parse. if it doesnt exist * then either load it from disk or parse it. * returns a new copy of the AST so you must delete it later. */ Util::ReferenceCount<Ast::AstParse> Parser::parse(const Filesystem::AbsolutePath & path){ PaintownUtil::Thread::ScopedLock scoped(lock); if (cache[path] == NULL){ cache[path] = loadFile(path); } return cache[path]; }
BSONObj FailPoint::toBSON() const { BSONObjBuilder builder; scoped_lock scoped(_modMutex); builder.append("mode", _mode); builder.append("data", _data); return builder.obj(); }
void EXTDisjointTimerQuery::deleteQueryEXT(WebGLTimerQueryEXT* query) { WebGLExtensionScopedContext scoped(this); if (!query || scoped.isLost()) return; query->deleteObject(scoped.context()->contextGL()); if (query == m_currentElapsedQuery) m_currentElapsedQuery.clear(); }
GLboolean EXTDisjointTimerQuery::isQueryEXT(WebGLTimerQueryEXT* query) { WebGLExtensionScopedContext scoped(this); if (!query || scoped.isLost() || query->isDeleted() || !query->validate(0, scoped.context())) { return false; } return scoped.context()->webContext()->isQueryEXT(query->object()); }
BSONObj FailPoint::toBSON() const { BSONObjBuilder builder; stdx::lock_guard<stdx::mutex> scoped(_modMutex); builder.append("mode", _mode); builder.append("data", _data); return builder.obj(); }
WebGLTimerQueryEXT* EXTDisjointTimerQuery::createQueryEXT() { WebGLExtensionScopedContext scoped(this); if (scoped.isLost()) return nullptr; WebGLTimerQueryEXT* o = WebGLTimerQueryEXT::create(scoped.context()); scoped.context()->addContextObject(o); return o; }
bool ts_generator::gen_union(AST_Union*, UTL_ScopedName* name, const std::vector<AST_UnionBranch*>&, AST_Type*, const char*) { if (idl_global->is_dcps_type(name)) { std::cerr << "ERROR: union " << scoped(name) << " can not be used as a " "DCPS_DATA_TYPE (only structs can be Topic types)" << std::endl; return false; } return true; }
void connect_by_qt() { std::cout<<"main thread : "<<boost::this_thread::get_id()<<std::endl; runSomething obj; //obj.print_value(44); boost::strict_scoped_thread<> scoped(boost::thread( boost::bind(&worker_thread3, boost::ref(obj))) ); }
void InspectorOverlay::updateAllLifecyclePhases() { if (isEmpty()) return; AutoReset<bool> scoped(&m_inLayout, true); if (m_needsUpdate) { m_needsUpdate = false; rebuildOverlayPage(); } overlayMainFrame()->view()->updateAllLifecyclePhases(); }
String WebGLDebugShaders::getTranslatedShaderSource(WebGLShader* shader) { WebGLExtensionScopedContext scoped(this); if (scoped.isLost()) return String(); if (!scoped.context()->validateWebGLObject("getTranslatedShaderSource", shader)) return ""; GLStringQuery query(scoped.context()->contextGL()); return query.Run<GLStringQuery::TranslatedShaderSourceANGLE>( shader->object()); }
void connect_from_main_thread() { boost::signals2::signal<void()> signal; signal.connect(print_something); signal(); std::cout<<"main thread : "<<boost::this_thread::get_id()<<std::endl; boost::strict_scoped_thread<> scoped(boost::thread( boost::bind(&worker_thread, boost::ref(signal))) ); }
static STGMEDIUM* GetStorageForBytes(const char* data, size_t bytes) { HANDLE handle = GlobalAlloc(GPTR, static_cast<int>(bytes)); base::win::ScopedHGlobal<char> scoped(handle); size_t allocated = static_cast<size_t>(GlobalSize(handle)); memcpy(scoped.get(), data, allocated); STGMEDIUM* storage = new STGMEDIUM; storage->hGlobal = handle; storage->tymed = TYMED_HGLOBAL; storage->pUnkForRelease = NULL; return storage; }
std::wstring VNCServer::GetEditorName() { //Increase usage while in method ScopedUse scoped(use); //If we got another editor if (this->editorId) { //Find it Clients::iterator it = clients.find(this->editorId); //If found if (it!=clients.end()) //Set client view onlu return it->second->GetName(); } //Empty return std::wstring(); }