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.pswp.cn/news/446843.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/446843.shtml
英文地址,請注明出處:http://en.pswp.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、刪掉…