void task::enqueue(task_worker_pool* pool) { this->add_ref(); // released in exec_internal (even when cancelled) if (spec().type == TASK_TYPE_COMPUTE) { spec().on_task_enqueue.execute(task::get_current_task(), this); } // for delayed tasks, refering to timer service if (_delay_milliseconds != 0) { pool->add_timer(this); return; } // fast execution if (_is_null) { dassert (_node == task::get_current_node(), ""); exec_internal(); } else if (_spec->fast_execution_in_network_thread) { if (_node != task::get_current_node()) { tools::node_scoper ns(_node); exec_internal(); } else { exec_internal(); } } else if (_spec->allow_inline && !task::get_current_worker2() /*in io-thread*/ ) { dassert(_node == task::get_current_node(), ""); exec_internal(); } // normal path else { dassert(pool != nullptr, "pool %s not ready, and there are usually two cases: " "(1). thread pool not designatd in '[%s] pools'; " "(2). the caller is executed in io threads " "which is forbidden unless you explicitly set [task.%s].fast_execution_in_network_thread = true", dsn_threadpool_code_to_string(_spec->pool_code), _node->spec().config_section.c_str(), _spec->name.c_str() ); pool->enqueue(this); } }
void task::enqueue(task_worker_pool *pool) { this->add_ref(); // released in exec_internal (even when cancelled) dassert(pool != nullptr, "pool %s not ready, and there are usually two cases: " "(1). thread pool not designatd in '[%s] pools'; " "(2). the caller is executed in io threads " "which is forbidden unless you explicitly set [task.%s].allow_inline = true", _spec->pool_code.to_string(), _node->spec().config_section.c_str(), _spec->name.c_str()); if (spec().type == TASK_TYPE_COMPUTE) { spec().on_task_enqueue.execute(get_current_task(), this); } // for delayed tasks, refering to timer service if (_delay_milliseconds != 0) { pool->add_timer(this); return; } // fast execution if (_is_null) { dassert(_node == task::get_current_node(), ""); exec_internal(); return; } if (_spec->allow_inline) { // inlined // warning - this may lead to deadlocks, e.g., allow_inlined // task tries to get a non-recursive lock that is already hold // by the caller task if (_node != get_current_node()) { tools::node_scoper ns(_node); exec_internal(); return; } else { exec_internal(); return; } } // normal path pool->enqueue(this); }
void task::enqueue(task_worker_pool* pool) { if (spec().type == TASK_TYPE_COMPUTE) { spec().on_task_enqueue.execute(task::get_current_task(), this); } // fast execution if (_delay_milliseconds == 0 && (_spec->allow_inline || _spec->fast_execution_in_network_thread || _is_null) ) { exec_internal(); } // normal path else { dassert(pool != nullptr, "pool not exist, " "must be the case where the caller is executed in io threads " "which is forbidden unless you explicitly set [task.%s].fast_execution_in_network_thread = true", _spec->name ); task_ptr this_(this); pool->enqueue(this_); } }
void sqlite3::execMany(call_context & x) { local_root_scope scope; if (x.arg.size() != 1) { throw exception ("SQLite3.execMany() requires 1 argument"); } if ( x.arg[0].is_object() && x.arg[0].get_object().is_array() ) { x.result = exec_internal( x.arg[0].to_object() ); } else { throw exception("SQLite3.execMany() expected an array of" " objects as argument"); } }
void sqlite3::exec(call_context & x) { local_root_scope scope; if (x.arg.size() != 1 && x.arg.size() != 2) { throw exception ("SQLite3.exec() requires at least 1 argument"); } if ( x.arg[0].is_string() ) { object data = create<object>(); data.set_property("sql", x.arg[0].get_string() ); if ( x.arg.size() > 1 ) { data.set_property( "bind", x.arg[1].to_object() ); } array arr(create<array>(list_of(data))); x.result = exec_internal( arr ); } else { throw exception("The first parameter of SQLite3.exec() requires to be" " a string containing an SQL statement"); } }
int exec(const std::string &subject, int startoffset = 0, int options = 0) const { return exec_internal(subject.data(), subject.length(), startoffset, options); }
// result: error code or zero-based offset of pattern match int exec(const char *subject, int startoffset = 0, int options = 0) const { return exec_internal(subject, subject != 0 ? strlen(subject) : 0, startoffset, options); }
// matching // result: same as pcre_exec(...) int exec(const char *subject, int *ovector, size_t ovecsize, int startoffset = 0, int options = 0) const { return exec_internal(subject, subject != 0 ? strlen(subject) : 0, ovector, ovecsize, startoffset, options); }
AbstractQoreNode* Datasource::execRaw(const QoreString* query_str, ExceptionSink* xsink) { return exec_internal(false, query_str, 0, xsink); }
// deprecated: remove due to extraneous ignored "args" argument AbstractQoreNode* Datasource::execRaw(const QoreString* query_str, const QoreListNode* args, ExceptionSink* xsink) { assert(!args); return exec_internal(false, query_str, 0, xsink); }
AbstractQoreNode* Datasource::exec(const QoreString* query_str, const QoreListNode* args, ExceptionSink* xsink) { return exec_internal(true, query_str, args, xsink); }