Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
#include <string>
#include <strstream>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
namespace pt = boost::property_tree;
int main(const int ac, const char* const * const av)
{
#include <iostream>
#include <boost/program_options.hpp>
namespace po = boost::program_options;
int main(const int ac, const char* const * const av)
{
// オプションの定義
po::options_description description("option");
description.add_options()
#include <iostream>
#include <boost/thread.hpp>
#define LOOP_NUM 5
static int num = 0;
// mutex
boost::shared_mutex mtx_;
#include <iostream>
#include <boost/thread.hpp>
#define LOOP_NUM 5
static int num = 0;
// mutex
boost::mutex mtx_;
#include <iostream>
#include <boost/thread.hpp>
#define LOOP_NUM 5
static int count = 0;
// 再帰的にロックをとっても大丈夫なmutex
boost::recursive_mutex mtx_;
#include <iostream>
#include <boost/thread.hpp>
#define LOOP_NUM 5
static int count = 0;
// mutex用の変数
boost::mutex mtx_;
#include <iostream>
#include <boost/thread.hpp>
#define LOOP_NUM 5
// 適当なクラス
class Hoge {
public:
// Hogeクラスのコンストラクタ
#include <iostream>
#include <boost/thread.hpp>
#define LOOP_NUM 5
// 文字列を加工して返す関数
std::string Modify(std::string str) {
std::cout << str << std::endl;
return str + " is modified.";
#include <iostream>
#include <boost/thread.hpp>
#define LOOP_NUM 5
// 引数の文字列を標準出力する関数
void Print(std::string str) {
for(int i = 0; i != LOOP_NUM; i++) {
// strの内容を標準出力(標準出力はスレッドセーフじゃないから本当は排他制御が必要だけど今回は省略)
std::cout << str << std::endl;
#include <iostream>
#include <boost/thread.hpp>
#define LOOP_NUM 5
// hogehogeと標準出力する関数
void Hoge() {
for(int i = 0; i != LOOP_NUM; i++) {
// hogehogeと標準出力(標準出力はスレッドセーフじゃないから本当は排他制御が必要だけど今回は省略)
std::cout << "hogehoge" << std::endl;