返回介绍

QLock Class

发布于 2019-10-04 15:01:21 字数 2541 浏览 1198 评论 0 收藏 0

The QLock class is a wrapper for a System V shared semaphore. More...

#include <qlock_qws.h>

List of all member functions.

Public Members

  • QLock ( constQString&filename, charid, boolcreate = FALSE )
  • ~QLock ()
  • enum Type { Read, Write }
  • bool isValid () const
  • void lock ( Typet )
  • void unlock ()
  • bool locked () const

Detailed Description

The QLock class is a wrapper for a System V shared semaphore.

It is used by Qt/Embedded for synchronizing access to the graphics card and shared memory region between processes.

See also Input/Output and Networking and Qt/Embedded.


Member Type Documentation

QLock::Type

  • QLock::Read
  • QLock::Write

Member Function Documentation

QLock::QLock ( constQString&filename, charid, boolcreate = FALSE )

Creates a lock. filename is the file path of the Unix-domain socket the Qt/Embedded client is using. id is the name of the particular lock to be created on that socket. If create is TRUE the lock is to be created (as the Qt/Embedded server does); if create is FALSE the lock should exist already (as the Qt/Embedded client expects).

QLock::~QLock ()

Destroys a lock

bool QLock::isValid () const

Returns TRUE if the lock constructor was succesful; returns FALSE if the lock could not be created or was not available to connect to.

void QLock::lock ( Typet )

Locks the semaphore with a lock of type t. Locks can either be Read or Write. If a lock is Read, attempts by other processes to obtain Read locks will succeed, and Write attempts will block until the lock is unlocked. If locked as Write, all attempts to lock by other processes will block until the lock is unlocked. Locks are stacked: i.e. a given QLock can be locked multiple times by the same process without blocking, and will only be unlocked after a corresponding number of unlock() calls.

bool QLock::locked () const

Returns TRUE if the lock is currently held by the current process; otherwise returns FALSE.

void QLock::unlock ()

Unlocks the semaphore. If other processes were blocking waiting to lock() the semaphore, one of them will wake up and succeed in lock()ing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文