IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

Thread Support

QDoc Manual.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

Thread Support▲

<Unknown command>contentspageQDoc Manual

The thread support commands are for specifying the level of support for multithreaded programming in a class or function. There are three levels of support: threadsafe, reentrant and nonreentrant.

The default is nonreentrant which means that the associated class or function cannot be called by multiple threads. Reentrant and threadsafe are levels primarily used for classes.

Reentrant means that all the functions in the referenced class can be called simultaneously by multiple threads, provided that each invocation of the functions reference unique data. While threadsafe means that all the functions in the referenced class can be called simultaneously by multiple threads even when each invocation references shared data.

When a class is marked https:// or https://, functions in that class can be marked nonreentrant using the https:// command.

Example▲

 
 
Sélectionnez
\beginqdoc
    \class QLocale
    \brief The QLocale class converts between numbers and their
    string representations in various languages.

    \reentrant
    \ingroup i18n
    \ingroup text

    QLocale is initialized with a language/country pair in its
    constructor and offers number-to-string and string-to-number
    conversion functions similar to those in QString.

    ...

    \nonreentrant

    Sets the global default locale to \a locale. These values are
    used when a QLocale object is constructed with no
    arguments. If this function is not called, the system's locale
    is used.

    \warning In a multithreaded application, the default locale
    should be set at application startup, before any non-GUI
    threads are created.

    \sa system(), c()
\endqdoc
void QLocale::setDefault(const QLocale &amp;locale)
{
    default_d = locale.d;
}

QDoc renders this as:

<center>QLocale Class Reference</center>

The QLocale class converts between numbers and their string representations in various languages. More...

 
Sélectionnez
#include &lt;QLocale&gt;

Note: All the functions in this class are https://, except setDefault().

...


Member Type Documentation

...

void QLocale::setDefault ( const QLocale & locale )

Sets the global default locale to locale. These values are used when a QLocale object is constructed with no arguments. If this function is not called, the system's locale is used.

In a multithreaded application, the default locale should be set at application startup, before any non-GUI threads are created.

This function is not reentrant.

See also system() and c().

...

As shown above, QDoc generates a notification when a class is declared reentrant, and lists the exceptions (the declared nonreentrant functions). A link to the general documentation on https:// is included. In addition a warning, "Warning: This function is not reentrant.", is generated in the nonreentrant functions' documentation.

QDoc will generate the same notification and warnings when a class is declared threadsafe.

For more information see the general documentation on https://.

Commands▲

   

\threadsafe▲

The \threadsafe command includes a line in the documentation to indicate that the associated class or function is threadsafe and can be called simultaneously by multiple threads, even when separate invocations reference shared data.

The command must stand on its own line.

The documentation generated from this command will be similar to the what is generated for the https:// command. See the example above in the https://.

See also https:// and https://.

 

\reentrant▲

The \reentrant command indicates that the associated class or function can be called simultaneously by multiple threads, provided that each invocation references its own data. See the https:// above.

The command must stand on its own line.

See also https:// and https://.

 

\nonreentrant▲

The \nonreentrant command indicates that the associated class or function cannot be called by multiple threads. Nonreentrant is the default case.

The command must stand on its own line.

When a class is marked https:// or https://, functions in that class can be marked nonreentrant using this command in the https:// comment of the functions to be excluded.

See also https:// and https://.

https://   https://

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+   

Ce document est disponible sous la licence https:// telle que publiée par la Free Software Foundation.