本文整理汇总了C++中detach函数的典型用法代码示例。如果您正苦于以下问题:C++ detach函数的具体用法?C++ detach怎么用?C++ detach使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了detach函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
//.........这里部分代码省略.........
示例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
//.........这里部分代码省略.........
示例3: detach
void WindowMaterialGlazingInspectorView::onClearSelection()
{
ModelObjectInspectorView::onClearSelection(); // call parent implementation
detach();
}
示例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;
}
示例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);
}
示例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);
}
示例7: attach
void attach(string_type& string) {
detach();
this->string = boost::addressof(string);
}
示例8: detach
void MaterialAirWallInspectorView::onClearSelection()
{
ModelObjectInspectorView::onClearSelection(); // call parent implementation
detach();
}
示例9: detach
QWSSharedMemory::~QWSSharedMemory()
{
detach();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例15: detach
/*!
Sets the \a user used for authentication.
\sa QNetworkAccessManager::authenticationRequired()
*/
void QAuthenticator::setUser(const QString &user)
{
detach();
d->user = user;
d->updateCredentials();
}