• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ detach函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中detach函数的典型用法代码示例。如果您正苦于以下问题:C++ detach函数的具体用法?C++ detach怎么用?C++ detach使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了detach函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: NdbMutex_Lock

void
AsyncIoThread::run()
{
  bool first_flag = true;
  Request *request;
  NDB_TICKS last_yield_ticks;

  // Create theMemoryChannel in the thread that will wait for it
  NdbMutex_Lock(theStartMutexPtr);
  theStartFlag = true;
  NdbMutex_Unlock(theStartMutexPtr);
  NdbCondition_Signal(theStartConditionPtr);

  EmulatedJamBuffer jamBuffer;
  jamBuffer.theEmulatedJamIndex = 0;
  // This key is needed by jamNoBlock().
  NdbThread_SetTlsKey(NDB_THREAD_TLS_JAM, &jamBuffer);

  while (1)
  {
    if (m_real_time)
    {
      /**
       * If we are running in real-time we'll simply insert a break every
       * so often to ensure that low-prio threads aren't blocked from the
       * CPU, this is especially important if we're using a compressed
       * file system where lots of CPU is used by this thread.
       */
      bool yield_flag = false;
      const NDB_TICKS current_ticks = NdbTick_getCurrentTicks();

      if (first_flag)
      {
        first_flag = false;
        yield_flag = true;
      }
      else
      {
        Uint64 micros_passed =
          NdbTick_Elapsed(last_yield_ticks, current_ticks).microSec();
        if (micros_passed > 10000)
        {
          yield_flag = true;
        }
      }
      if (yield_flag)
      {
        if (NdbThread_yield_rt(theThreadPtr, TRUE))
        {
          m_real_time = false;
        }
        last_yield_ticks = current_ticks;
      }
    }
    request = theMemoryChannelPtr->readChannel();
    if (!request || request->action == Request::end)
    {
      DEBUG(ndbout_c("Nothing read from Memory Channel in AsyncFile"));
      theStartFlag = false;
      return;
    }//if

    AsyncFile * file = request->file;
    m_current_request= request;
    switch (request->action) {
    case Request::open:
      file->openReq(request);
      if (request->error == 0 && request->m_do_bind)
        attach(file);
      break;
    case Request::close:
      file->closeReq(request);
      detach(file);
      break;
    case Request::closeRemove:
      file->closeReq(request);
      file->removeReq(request);
      detach(file);
      break;
    case Request::readPartial:
    case Request::read:
      file->readReq(request);
      break;
    case Request::readv:
      file->readvReq(request);
      break;
    case Request::write:
      file->writeReq(request);
      break;
    case Request::writev:
      file->writevReq(request);
      break;
    case Request::writeSync:
      file->writeReq(request);
      file->syncReq(request);
      break;
    case Request::writevSync:
      file->writevReq(request);
      file->syncReq(request);
      break;
//.........这里部分代码省略.........
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:101,代码来源:AsyncIoThread.cpp


示例2: array

QT_BEGIN_NAMESPACE

/*****************************************************************************
  Q3CString member functions
 *****************************************************************************/

/*!
    \class Q3CString
    \reentrant
    \brief The Q3CString class provides an abstraction of the classic C
    zero-terminated char array (char *).

    \compat

    Q3CString tries to behave like a more convenient \c{const char *}.
    The price of doing this is that some algorithms will perform
    badly. For example, append() is O(length()) since it scans for a
    null terminator. Although you might use Q3CString for text that is
    never exposed to the user, for most purposes, and especially for
    user-visible text, you should use QString. QString provides
    implicit sharing, Unicode and other internationalization support,
    and is well optimized.

    Note that for the Q3CString methods that take a \c{const char *}
    parameter the \c{const char *} must either be 0 (null) or not-null
    and '\0' (NUL byte) terminated; otherwise the results are
    undefined.

    A default constructed Q3CString is \e null, i.e. both the length
    and the data pointer are 0 and isNull() returns true.
    
    \note However, if you ask for the data pointer of a null Q3CString
    by calling data(), then because the internal representation of the
    null Q3CString is shared, it will be detached and replaced with a
    non-shared, empty representation, a non-null data pointer will be
    returned, and subsequent calls to isNull() will return false. But
    if you ask for the data pointer of a null Q3CString by calling
    constData(), the shared internal representation is not detached, a
    null data pointer is returned, and subsequent calls to isNull()
    will continue to return true.

    A Q3CString that references the empty string ("", a single '\0'
    char) is \e empty, i.e. isEmpty() returns true.  Both null and
    empty Q3CStrings are legal parameters to the methods.  Assigning
    \c{const char *} 0 to Q3CString produces a null Q3CString.

    The length() function returns the length of the string; resize()
    resizes the string and truncate() truncates the string. A string
    can be filled with a character using fill(). Strings can be left
    or right padded with characters using leftJustify() and
    rightJustify(). Characters, strings and regular expressions can be
    searched for using find() and findRev(), and counted using
    contains().

    Strings and characters can be inserted with insert() and appended
    with append(). A string can be prepended with prepend().
    Characters can be removed from the string with remove() and
    replaced with replace().

    Portions of a string can be extracted using left(), right() and
    mid(). Whitespace can be removed using stripWhiteSpace() and
    simplifyWhiteSpace(). Strings can be converted to uppercase or
    lowercase with upper() and lower() respectively.

    Strings that contain numbers can be converted to numbers with
    toShort(), toInt(), toLong(), toULong(), toFloat() and toDouble().
    Numbers can be converted to strings with setNum().

    Many operators are overloaded to work with Q3CStrings. Q3CString
    also supports some more obscure functions, e.g. sprintf(),
    setStr() and setExpand().

    \sidebar Note on Character Comparisons

    In Q3CString the notion of uppercase and lowercase and of which
    character is greater than or less than another character is locale
    dependent. This affects functions which support a case insensitive
    option or which compare or lowercase or uppercase their arguments.
    Case insensitive operations and comparisons will be accurate if
    both strings contain only ASCII characters. (If \c $LC_CTYPE is
    set, most Unix systems do "the right thing".) Functions that this
    affects include contains(), find(), findRev(), \l operator<(), \l
    operator<=(), \l operator>(), \l operator>=(), lower() and
    upper().

    This issue does not apply to \l{QString}s since they represent
    characters using Unicode.
    \endsidebar

    Performance note: The Q3CString methods for QRegExp searching are
    implemented by converting the Q3CString to a QString and performing
    the search on that. This implies a deep copy of the Q3CString data.
    If you are going to perform many QRegExp searches on a large
    Q3CString, you will get better performance by converting the
    Q3CString to a QString yourself, and then searching in the QString.
*/

/*!
    \fn Q3CString Q3CString::left(uint len)  const

//.........这里部分代码省略.........
开发者ID:RS102839,项目名称:qt,代码行数:101,代码来源:q3cstring.cpp


示例3: detach

void WindowMaterialGlazingInspectorView::onClearSelection()
{
  ModelObjectInspectorView::onClearSelection(); // call parent implementation
  detach();
}
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:5,代码来源:WindowMaterialGlazingInspectorView.cpp


示例4: main

int main(int argc, char *argv[])
{
    int nsockets = 0;
    struct event listeners[10];

    parseargs(argc, argv);

    if (g_foreground == 0) {
        detach();
        g_logfile = fopen(g_logfilename, "a");
        g_log_set_default_handler(logger, NULL);
    }

    g_handle_base[0] = 'H';
    g_handle_base[1] = ':';
    if (gethostname(g_handle_base+2, 128-28) != 0) {
        sprintf(g_handle_base+2, "hostname"); /* TODO: figure out some other unique identifier */
    }
    char *p = strchr(g_handle_base, '.');
    if (!p) p = g_handle_base + strlen(g_handle_base);
    *(p++) = ':';
    *p = 0;

    g_thread_init(NULL);

    event_init();
    //printf("%s %s\n", event_get_version(), event_get_method());

    signal(SIGPIPE, SIG_IGN);

    struct event sig_int, sig_hup, sig_term;/*, sig_pipe;*/
    if (g_foreground) {
        event_set(&sig_int, SIGINT, EV_SIGNAL|EV_PERSIST, signal_cb, &sig_int);
        event_add(&sig_int, NULL);
        event_set(&sig_hup, SIGHUP, EV_SIGNAL|EV_PERSIST, signal_cb, &sig_hup);
        event_add(&sig_hup, NULL);
    } else {
        signal(SIGINT, SIG_IGN);
        signal(SIGHUP, SIG_IGN);
    }
    event_set(&sig_term, SIGTERM, EV_SIGNAL|EV_PERSIST, signal_cb, &sig_term);
    event_add(&sig_term, NULL);
    /*event_set(&sig_pipe, SIGPIPE, EV_SIGNAL|EV_PERSIST, signal_cb, &sig_pipe);
    event_add(&sig_pipe, NULL);*/

    int s = listen_on(inet_addr(g_bind), g_port);
    if (s == -1) {
        perror("failed to listen on port ...");
        return -1;
    }
    event_set(&listeners[nsockets], s, EV_READ|EV_PERSIST,
              listener_cb, &listeners[nsockets]);
    event_add(&listeners[nsockets], NULL);
    nsockets++;

    g_message("listening on port %d", g_port);

    g_clients   = g_ptr_array_new();
    g_jobs = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, (GDestroyNotify)job_free);
    g_jobqueue = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)g_queue_free);
    g_uniq_jobs = g_hash_table_new_full(uniq_job_hash, uniq_job_equal, NULL, NULL);
    g_workers = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)g_ptr_array_free);

    schedule_cleanup();

    g_message("gearmand running");
    event_dispatch();
    g_message("gearmand stopped");

    g_hash_table_destroy(g_workers);
    g_hash_table_destroy(g_uniq_jobs);
    g_hash_table_destroy(g_jobqueue);
    g_hash_table_destroy(g_jobs);
    g_ptr_array_free(g_clients, TRUE);

    freePools();

    if (g_foreground == 0)
        fclose(g_logfile);

    return 0;
}
开发者ID:pombredanne,项目名称:gearwoman,代码行数:82,代码来源:gearmand.c


示例5: append

/*!
    Inserts the field \a field at position \a pos in the record.

    \sa append() replace() remove()
 */
void QSqlRecord::insert(int pos, const QSqlField& field)
{
   detach();
   d->fields.insert(pos, field);
}
开发者ID:husninazer,项目名称:qt,代码行数:10,代码来源:qsqlrecord.cpp


示例6: options

/*!
    \since 4.7

    Sets the outgoing option \a opt to value \a value.
    See \l{QAuthenticator#Options} for more information on outgoing options.

    \sa options(), option(), QAuthenticator#Options
*/
void QAuthenticator::setOption(const QString &opt, const QVariant &value)
{
    detach();
    d->options.insert(opt, value);
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:13,代码来源:qauthenticator.cpp


示例7: attach

 void attach(string_type& string) {
     detach();
     this->string = boost::addressof(string);
 }
开发者ID:Alukardd,项目名称:blackhole,代码行数:4,代码来源:streambuf.hpp


示例8: detach

void MaterialAirWallInspectorView::onClearSelection()
{
  ModelObjectInspectorView::onClearSelection(); // call parent implementation
  detach();
}
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:5,代码来源:MaterialAirWallInspectorView.cpp


示例9: detach

QWSSharedMemory::~QWSSharedMemory()
{
    detach();
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:4,代码来源:qwssharedmemory.cpp


示例10: textOption

/*!
   Sets the text option structure that controls the layout process to the given \a textOption.

   \sa textOption()
*/
void QStaticText::setTextOption(const QTextOption &textOption)
{
    detach();
    data->textOption = textOption;
    data->invalidate();
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:11,代码来源:qstatictext.cpp


示例11: size

/*!
    Sets the preferred width for this QStaticText. If the text is wider than the specified width,
    it will be broken into multiple lines and grow vertically. If the text cannot be split into
    multiple lines, it will be larger than the specified \a textWidth.

    Setting the preferred text width to a negative number will cause the text to be unbounded.

    Use size() to get the actual size of the text.

    \note This function will cause the layout of the text to require recalculation.

    \sa textWidth(), size()
*/
void QStaticText::setTextWidth(qreal textWidth)
{
    detach();
    data->textWidth = textWidth;
    data->invalidate();
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:19,代码来源:qstatictext.cpp


示例12: textFormat

/*!
   Sets the text format of the QStaticText to \a textFormat. If \a textFormat is set to
   Qt::AutoText (the default), the format of the text will try to be determined using the
   function Qt::mightBeRichText(). If the text format is Qt::PlainText, then the text will be
   displayed as is, whereas it will be interpreted as HTML if the format is Qt::RichText. HTML tags
   that alter the font of the text, its color, or its layout are supported by QStaticText.

   \note This function will cause the layout of the text to require recalculation.

   \sa textFormat(), setText(), text()
*/
void QStaticText::setTextFormat(Qt::TextFormat textFormat)
{
    detach();
    data->textFormat = textFormat;
    data->invalidate();
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:17,代码来源:qstatictext.cpp


示例13: text

/*!
    Sets the text of the QStaticText to \a text.

    \note This function will cause the layout of the text to require recalculation.

    \sa text()
*/
void QStaticText::setText(const QString &text)
{
    detach();
    data->text = text;
    data->invalidate();
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:13,代码来源:qstatictext.cpp


示例14: set_and_throw

/// Closes the file and throws on error.
void fstream::close (void)
{
    if (m_fd >= 0 && ::close(m_fd))
	set_and_throw (badbit | failbit, "close");
    detach();
}
开发者ID:treejames,项目名称:testSparrow,代码行数:7,代码来源:fstream.cpp


示例15: detach

/*!
  Sets the \a user used for authentication.

  \sa QNetworkAccessManager::authenticationRequired()
*/
void QAuthenticator::setUser(const QString &user)
{
    detach();
    d->user = user;
    d->updateCredentials();
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:11,代码来源:qauthenticator.cpp


示例16: detach

void Plot2DProfile::detachFromPlot(){
    detach();
}
开发者ID:Astroua,项目名称:CARTAvis,代码行数:3,代码来源:Plot2DProfile.cpp


示例17: detach

 void TreeInspector::close(Event* ev)
 {
     detach();
     _getStage()->removeEventListeners(this);
     //return true;
 }
开发者ID:HaoDongGuo,项目名称:oxygine-framework,代码行数:6,代码来源:TreeInspector.cpp


示例18: detach

/*!
  Destroys this QScriptDebuggerBackend.
*/
QScriptDebuggerBackend::~QScriptDebuggerBackend()
{
    detach();
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:7,代码来源:qscriptdebuggerbackend.cpp


示例19: initializeWatcher

//-------------------------------------------------------------------------------------
bool DBInterfaceMysql::attach(const char* databaseName)
{
	if(!_g_installedWatcher)
	{
		initializeWatcher();
	}

	if(db_port_ == 0)
		db_port_ = 3306;
	
	if(databaseName != NULL)
		kbe_snprintf(db_name_, MAX_BUF, "%s", databaseName);

	hasLostConnection_ = false;

	try
	{
		pMysql_ = mysql_init(0);
		if(pMysql_ == NULL)
		{
			ERROR_MSG("DBInterfaceMysql::attach: mysql_init is error!\n");
			return false;
		}
		
		DEBUG_MSG(fmt::format("DBInterfaceMysql::attach: connect: {}:{} starting...\n", db_ip_, db_port_));

		int ntry = 0;

__RECONNECT:
		if(mysql_real_connect(mysql(), db_ip_, db_username_, 
    		db_password_, db_name_, db_port_, NULL, 0)) // CLIENT_MULTI_STATEMENTS  
		{
			if(mysql_select_db(mysql(), db_name_) != 0)
			{
				ERROR_MSG(fmt::format("DBInterfaceMysql::attach: Could not set active db[{}]\n",
					db_name_));

				detach();
				return false;
			}
		}
		else
		{
			if (mysql_errno(pMysql_) == 1049 && ntry++ == 0)
			{
				if (mysql())
				{
					::mysql_close(mysql());
					pMysql_ = NULL;
				}

				pMysql_ = mysql_init(0);
				if (pMysql_ == NULL)
				{
					ERROR_MSG("DBInterfaceMysql::attach: mysql_init is error!\n");
					return false;
				}

				if (mysql_real_connect(mysql(), db_ip_, db_username_,
					db_password_, NULL, db_port_, NULL, 0)) // CLIENT_MULTI_STATEMENTS  
				{
					this->createDatabaseIfNotExist();
					if (mysql_select_db(mysql(), db_name_) != 0)
					{
						goto __RECONNECT;
					}
				}
				else
				{
					goto __RECONNECT;
				}
			}
			else
			{
				ERROR_MSG(fmt::format("DBInterfaceMysql::attach: mysql_errno={}, mysql_error={}\n",
					mysql_errno(pMysql_), mysql_error(pMysql_)));

				detach();
				return false;
			}
		}

		if (mysql_set_character_set(mysql(), "utf8") != 0)
		{
			ERROR_MSG("DBInterfaceMysql::attach: Could not set client connection character set to UTF-8\n" );
			return false;
		}

		// 不需要关闭自动提交,底层会START TRANSACTION之后再COMMIT
		// mysql_autocommit(mysql(), 0);

		char characterset_sql[MAX_BUF];
		kbe_snprintf(characterset_sql, MAX_BUF, "ALTER DATABASE CHARACTER SET %s COLLATE %s", 
			characterSet_.c_str(), collation_.c_str());

		query(&characterset_sql[0], strlen(characterset_sql), false);
	}
	catch (std::exception& e)
	{
//.........这里部分代码省略.........
开发者ID:hxingchh,项目名称:kbengine,代码行数:101,代码来源:db_interface_mysql.cpp


示例20: detach

void QSqlRecord::append(const QSqlField& field)
{
    detach();
    d->fields.append(field);
}
开发者ID:husninazer,项目名称:qt,代码行数:5,代码来源:qsqlrecord.cpp



注:本文中的detach函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ detail函数代码示例发布时间:2022-05-30
下一篇:
C++ det函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap