C++boost Class named_condition翻译

Class named_condition

  • boost::interprocess::named_condition

简介

// In header: <boost/interprocess/sync/named_condition.hpp>class named_condition {
public:// construct/copy/destructnamed_condition(create_only_t, const char *, const permissions & = permissions());named_condition(open_or_create_t, const char *, const permissions & = permissions());named_condition(open_only_t, const char *);~named_condition();// public member functions*void notify_one();void notify_all();template<typename L> void wait(L &);template<typename L, typename Pr> void wait(L &, Pr);template<typename L> bool timed_wait(L &, const boost::posix_time::ptime &);template<typename L, typename Pr> bool timed_wait(L &, const boost::posix_time::ptime &, Pr);// public static functionsstatic bool remove(const char *);
};

Description

  • A global condition variable that can be created by name. This condition variable is designed to work with named_mutex and can't be placed in shared memory or memory mapped files.
  • 一个全局条件变量,可以通过名字来创建。这个条件变量被设计成与named_mutex一起工作,不能放在共享内存或内存映射文件中。

named_condition public construct/copy/destruct

  • named_condition(create_only_t create_only, const char * name, const permissions & perm = permissions());
  • Creates a global condition with a name. If the condition can't be created throws interprocess_exception
  • 创建一个带有名称的全局条件。如果条件不能被创建,则抛出interprocess_exception。

 

  • named_condition(open_or_create_t open_or_create, const char * name,
    const permissions & perm = permissions());
  • Opens or creates a global condition with a name. If the condition is created, this call is equivalent to named_condition(create_only_t, ... ) If the condition is already created, this call is equivalent named_condition(open_only_t, ... ) Does not throw
  • 打开或创建一个带有名称的全局条件。如果条件已经创建,这个调用相当于 named_condition(create_only_t, ... ) 如果条件已经创建,这个调用相当于 named_condition(open_only_t, ... ) 不抛出

 

  • named_condition(open_only_t open_only, const char * name);
  • Opens a global condition with a name if that condition is previously created. If it is not previously created this function throws interprocess_exception.
  • 如果之前创建了一个带有名称的全局条件,则打开该条件。如果之前没有创建,则该函数会引发interprocess_exception。

 

  • ~named_condition();
  • Destroys *this and indicates that the calling process is finished using the resource. The destructor function will deallocate any system resources allocated by the system for use by this process for this resource. The resource can still be opened again calling the open constructor overload. To erase the resource from the system use remove().
  • 销毁*this,并表示调用进程使用该资源结束。该破坏函数将去分配系统为该资源分配的任何系统资源,供该进程使用。该资源仍然可以调用open构造函数重载再次打开。要从系统中删除资源,使用remove()。

named_condition public member functions 

  • *void notify_one();
  • If there is a thread waiting on *this, change that thread's state to ready. Otherwise there is no effect.
  • 如果有一个线程在等待*this,则将该线程的状态改为ready。否则没有任何影响。

 

  • void notify_all();
  • Change the state of all threads waiting on *this to ready. If there are no waiting threads, notify_all() has no effect.
  • 将所有在*this上等待的线程的状态改为ready。如果没有等待的线程,notify_all()就没有效果。

 

  • template<typename L> void wait(L & lock);
  • Releases the lock on the named_mutex object associated with lock, blocks the current thread of execution until readied by a call to this->notify_one() or this->notify_all(), and then reacquires the lock.
  • 释放与锁相关联的named_mutex对象的锁,阻止当前线程的执行,直到调用this->notify_one()或this->notify_all()准备好,然后重新获取锁。

 

  • template<typename L, typename Pr> void wait(L & lock, Pr pred);
  • The same as: while (!pred()) wait(lock)

 

  • template<typename L> bool timed_wait(L & lock, const boost::posix_time::ptime & abs_time);
  • Releases the lock on the named_mutex object associated with lock, blocks the current thread of execution until readied by a call to this->notify_one() or this->notify_all(), or until time abs_time is reached, and then reacquires the lock. Returns: false if time abs_time is reached, otherwise true.
  • 释放与锁相关联的named_mutex对象的锁,阻止当前线程的执行,直到调用this->notify_one()或this->notify_all(),或者直到达到时间abs_time,然后重新获取锁。返回:如果达到时间abs_time,则返回false,否则返回true。

 

  • template<typename L, typename Pr>bool timed_wait(L & lock, const boost::posix_time::ptime & abs_time, Pr pred);
  • The same as: while (!pred()) { if (!timed_wait(lock, abs_time)) return pred(); } return true;

named_condition public static functions

  • static bool remove(const char * name);
  • Erases a named condition from the system. Returns false on error. Never throws.
  • 从系统中删除一个命名的条件。错误时返回false。绝不抛出。
     
  

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/446843.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Android Studio 代理设置以及代理完全清除

目录一、代理设置二、代理完全清除一、代理设置 首先我们来看下怎样设置代理&#xff0c;Mac下打开【Preferences…】&#xff0c;然后搜索"HTTP"&#xff0c;选择【HTTP Proxy】&#xff0c;按图中设置配置好后&#xff0c;点击【Apply】&#xff0c;然后在点击【O…

安卓布局位置,dp与px的区别

手机6寸—指对角线 布局位置 横轴—x轴 纵轴—y轴 一个像素点 dp与Px dp:设备无关像素,与像素密度相关,像素距离 dpi:像素密度,每英寸包含的像素数 px:屏幕上一个物理像素点 ldpi低密度 1dp0.75px mdpi中密度 1dp1px hdpi高密度 1dp1.5px xhdpi超高密度 1dp2px xxhdpi超…

Android Studio 快捷键大全(Mac系统)

目录一、Mac上的按键符号二、快捷键查找/查看相关控制操作相关代码重构相关一、Mac上的按键符号 符号说明⌥option / alt⇧shift⌃control⌘command⎋esc 二、快捷键 查找/查看相关 快捷键说明双击 shift搜索任意内容command F / command R当前文件查找/替换&#xff0c;使…

ubuntu下clion软件连接boost库文件

整体配置 cmake_minimum_required(VERSION 3.17) project(mutex_learn)set(CMAKE_CXX_STANDARD 14) #boost库所在的根目录set(BOOST_ROOT "/usr/local/include/boost") #添加头文件搜索路径 include_directories(/usr/local/include) #添加库文件搜索路径 link_dir…

Android程序结构

Project方式 .gradle文件夹:编译相关生成 .idea文件夹:idea生成 app文件夹----应用程序的源代码和资源 build----编译后的文件存放的位置,最终apk文件存放的位置 libs:存放.jar和.so文件 src:AndroidTest与test存放测试相关的内容 main中Java文件夹存放Java源码,res文件…

通过Github创建Android库供其他项目依赖引用

目录一、简介二、实现第一步&#xff1a;将自己的项目托管到Github上。第二步&#xff1a;点击releases。第三步&#xff1a;创建release。第四步&#xff1a;填写版本号、名称、描述信息。第五步&#xff1a;点击【Publish release】。第六步&#xff1a;复制项目路径。第七步…

使用boost模板函数实现读写锁

介绍 shared_mutex即读写锁&#xff0c;不同与我们常用的独占式锁mutex&#xff0c;shared_mutex是共享与独占共存的锁&#xff0c;实现了读写锁的机制&#xff0c;即多个读线程一个写线程&#xff0c;通常用于对于一个共享区域的读操作比较频繁&#xff0c;而写操作比较少的情…

安卓内边距padding与外边距magrin

内边距padding与外边距margin 内边距只有容器才有,即里面要有视图 具体示例

Android Studio发布项目到jcenter

目录一、创建Bintray账户及Maven仓库二、上传项目到jcenter1、配置Android项目2、Gradle命令上传3、在项目中引用4、Add to JCenter三、Demo示例一、创建Bintray账户及Maven仓库 1、打开Bintray首页&#xff0c;点击 For an Open Source Account &#xff0c;快速注册或者用第…

C++读取文件,将文件内容读到string字符串里面

使用stringstream和ifstream实现 代码 std::ifstream f{file_name, std::ios::binary};std::stringstream ss;ss << f.rdbuf();auto data ss.str();

Android MotionEvent中getX()、getRawX()和getTop()的区别

为了展示getX()、getRawX()和getTop()方法的区别&#xff0c;我们写了一个简单的测试Demo&#xff0c;我们写了一个自定义控件&#xff08;继承ImageView&#xff09;。 package com.demo.ui;import android.content.Context; import android.support.annotation.Nullable; im…

C++常量

常量 1.字面常量与符号常量 字面常量:从字面形式可以识别的常量 eg:1.2;‘A’ 整型常量:八进制(以0开头),十六进制(以0x或0X开头) 浮点型常量: 小数形式(整数和小数可以省略其中之一------为0时) eg:.123(0.123) 123.(123.0) 指数形式 0.23e1(0.2310^1) 0.23E-2(0.2310^-2)…

Synchronization 进程锁

Boost.Interprocess允许多个进程同时使用共享内存。因为共享内存从定义上来说是进程间共享的&#xff0c;所以Boost.Interprocess需要支持某种同步。想到同步&#xff0c;我们会想到C11标准库中的类或Boost.Thread。但是这些类只能用来同步同一进程内的线程&#xff0c;它们不支…

Android 获取屏幕宽度和高度的几种方法

方法一&#xff1a; public static void getScreenSize1(Context context){WindowManager windowManager (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);Display defaultDisplay windowManager.getDefaultDisplay();Point point new Point();defaultD…

毛概 第二章新民主主义革命理论

1.新民主主义革命的总路线 2.

解决undefined reference to symbol ‘sem_close@@GLIBC_2.2.5‘问题

错误图示 问题原因 编译的时候&#xff0c;没有引入库文件 sem()位于pthread库中&#xff0c;所以在编译和链接时请确保使用-pthread标志&#xff0c;因此在编译的时候需要导入pthread库文件编译的顺序出现问题 解决办法 在clion的CMakeLists.txt文件中添加这一行代码set(CM…

Android 在onCreate()方法中获取控件宽高值为0解决方案

大家很多时候需要在Activity或者Fragment的onCreate()方法中获取声明的空间的高度或者宽度&#xff0c;进行位置移动或者其他操作&#xff0c;但是当调用 view.getHeight() 或者 view.getWidth() 获取的竟然为0。。。 其实很容易理解&#xff0c;在onCreate()的时候&#xff0…

C++运算符与类型转换

除法/ 参与运算时,结果符号按照(为,–为,-或为-),两个都是整型结果直接去除小数部分 -3/1-1 -3/-13 3/-13 除法 一律向0取整&#xff08;即直接切除小数部分&#xff09;。 取余% 参与运算为整型,结果符号和第一个相同(当结果不为0时) /* 21%63 -21%6-3 -21%-6-3 参与取余的运…

使用named_mutex实现锁机制

介绍 named_mutex是一个进程锁&#xff0c;考虑到进程和线程之间的区别区别&#xff1a;一个工作单元要想被称作进程&#xff0c;它必须要有操作系统指派给他的地址空间&#xff0c;必须拥有进程ID&#xff0c;必须拥有状态和进程表中的表项。进程和线程之间最大的区别是进程有…

Android Studio 突然出现很多红色波浪线或红色感叹号解决方案

最近在开发过程中&#xff0c;某次打开Android工程之后&#xff0c;代码了出现大量的红色波浪线报错提示&#xff0c;但是工程确可以正常编译、正常打包&#xff0c;尝试了很多方法都无法去掉&#xff0c;最后找到了最有效的解决方案&#xff0c;步骤如下&#xff1a; 1、删掉…