当前位置: 首页>>代码示例>>C++>>正文


C++ Flag类代码示例

本文整理汇总了C++中Flag的典型用法代码示例。如果您正苦于以下问题:C++ Flag类的具体用法?C++ Flag怎么用?C++ Flag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Flag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TEST

TEST(Flag, MultiThreaded)
{
	Flag f;
	int count = 0;
	const int ITERATIONS_COUNT = 100000;

	auto setter = [&]() {
		for (int i = 0; i < ITERATIONS_COUNT; ++i)
		{
			while (f.IsSet());
			f.Set();
		}
	};

	auto clearer = [&]() {
		for (int i = 0; i < ITERATIONS_COUNT; ++i)
		{
			while (!f.IsSet());
			count++;
			f.Clear();
		}
	};

	std::thread setter_thread(setter);
	std::thread clearer_thread(clearer);

	setter_thread.join();
	clearer_thread.join();

	EXPECT_EQ(ITERATIONS_COUNT, count);
}
开发者ID:Abrahamh08,项目名称:dolphin,代码行数:31,代码来源:FlagTest.cpp

示例2: address_of_flag

void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) {
  Flag* faddr = address_of_flag(flag);
  guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
  trace_flag_changed<EventDoubleFlagChanged, double>(faddr->_name, faddr->get_double(), value, origin);
  faddr->set_double(value);
  faddr->set_origin(origin);
}
开发者ID:mengna152173,项目名称:openjdk8u20-profiling,代码行数:7,代码来源:globals.cpp

示例3: uintxAt

Flag::Error CommandLineFlags::uintxAt(const char* name, size_t len, uintx* value, bool allow_locked, bool return_flag) {
  Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
  if (result == NULL) return Flag::INVALID_FLAG;
  if (!result->is_uintx()) return Flag::WRONG_FORMAT;
  *value = result->get_uintx();
  return Flag::SUCCESS;
}
开发者ID:gaoxiaojun,项目名称:dync,代码行数:7,代码来源:globals.cpp

示例4: boolAtPut

bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, Flag::Flags origin) {
  Flag* result = Flag::find_flag(name, len);
  if (result == NULL) return false;
  if (!result->is_bool()) return false;
  bool old_value = result->get_bool();
  trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin);
  result->set_bool(*value);
  *value = old_value;
  result->set_origin(origin);
  return true;
}
开发者ID:mengna152173,项目名称:openjdk8u20-profiling,代码行数:11,代码来源:globals.cpp

示例5:

Flag& Flag::get(const std::string& name,
                const std::string& type,
                const std::string& value,
                const std::string& desc,
                bool shell_only) {
  static Flag f;
  if (name != "") {
    f.add(name, type, value, desc, shell_only);
  }
  return f;
}
开发者ID:kevin25,项目名称:osquery,代码行数:11,代码来源:flags.cpp

示例6: ccstrAtPut

// Contract:  Flag will make private copy of the incoming value.
// Outgoing value is always malloc-ed, and caller MUST call free.
bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin) {
  Flag* result = Flag::find_flag(name, len);
  if (result == NULL) return false;
  if (!result->is_ccstr()) return false;
  ccstr old_value = result->get_ccstr();
  trace_flag_changed<EventStringFlagChanged, const char*>(name, old_value, *value, origin);
  char* new_value = NULL;
  if (*value != NULL) {
    new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1, mtInternal);
    strcpy(new_value, *value);
  }
开发者ID:mengna152173,项目名称:openjdk8u20-profiling,代码行数:13,代码来源:globals.cpp

示例7: doubleAtPut

bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, Flag::Flags origin) {
  Flag* result = Flag::find_flag(name, len);
  if (result == NULL) return false;
  if (!result->is_double()) return false;
  double old_value = result->get_double();
  trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin);
  result->set_double(*value);
  *value = old_value;
  result->set_origin(origin);
  return true;
}
开发者ID:mengna152173,项目名称:openjdk8u20-profiling,代码行数:11,代码来源:globals.cpp

示例8:

bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, Flag::Flags origin) {
  Flag* result = Flag::find_flag(name, len);
  if (result == NULL) return false;
  if (!result->is_uint64_t()) return false;
  uint64_t old_value = result->get_uint64_t();
  trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
  result->set_uint64_t(*value);
  *value = old_value;
  result->set_origin(origin);
  return true;
}
开发者ID:mengna152173,项目名称:openjdk8u20-profiling,代码行数:11,代码来源:globals.cpp

示例9: intxAtPut

bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, Flag::Flags origin) {
  Flag* result = Flag::find_flag(name, len);
  if (result == NULL) return false;
  if (!result->is_intx()) return false;
  intx old_value = result->get_intx();
  trace_flag_changed<EventLongFlagChanged, s8>(name, old_value, *value, origin);
  result->set_intx(*value);
  *value = old_value;
  result->set_origin(origin);
  return true;
}
开发者ID:mengna152173,项目名称:openjdk8u20-profiling,代码行数:11,代码来源:globals.cpp

示例10: BOOST_MESSAGE

void QuoteTest::testObservable() {

    BOOST_MESSAGE("Testing observability of quotes...");

    boost::shared_ptr<SimpleQuote> me(new SimpleQuote(0.0));
    Flag f;
    f.registerWith(me);
    me->setValue(3.14);

    if (!f.isUp())
        BOOST_FAIL("Observer was not notified of quote change");

}
开发者ID:shlagbaum,项目名称:quantlib,代码行数:13,代码来源:quotes.cpp

示例11: set_flag

// Implementation of "setflag" command
static jint set_flag(AttachOperation* op, outputStream* out) {

  const char* name = NULL;
  if ((name = op->arg(0)) == NULL) {
    out->print_cr("flag name is missing");
    return JNI_ERR;
  }

  Flag* f = Flag::find_flag((char*)name, strlen(name));
  if (f && f->is_external() && f->is_writeable()) {
    if (f->is_bool()) {
      return set_bool_flag(name, op, out);
    } else if (f->is_intx()) {
      return set_intx_flag(name, op, out);
    } else if (f->is_uintx()) {
      return set_uintx_flag(name, op, out);
    } else if (f->is_uint64_t()) {
      return set_uint64_t_flag(name, op, out);
    } else if (f->is_ccstr()) {
      return set_ccstr_flag(name, op, out);
    } else {
      ShouldNotReachHere();
      return JNI_ERR;
    }
  } else {
    return AttachListener::pd_set_flag(op, out);
  }
}
开发者ID:641252154,项目名称:HotSpot-JVM-Linux-x86-Research,代码行数:29,代码来源:attachListener.cpp

示例12: ParseConfigFile

/**
 * Parses a config file with lines of the form
 *
 *     flag = value
 *
 * and sets flags as appropriate.
 */
Status ParseConfigFile() {
  Trace();
  if (!g_configFile.wasSet()) {
    Log(LL::Trace) << "No flag config file specified.";
    return Status::ok();
  }
  const std::string &filename = g_configFile.get();
  Log(LL::Trace) << "Begining parse of config file: " << filename;

  std::ifstream ifile(filename.c_str());
  if (!ifile.is_open()) {
    Log(LL::Trace) << "Config file " << filename << " not found.";
    return Status(Status::NOT_FOUND);
  }

  std::string line;
  int lineno = 0;
  while (std::getline(ifile, line)) {
    if (line.empty()) {
      lineno++;
      continue;
    }

    std::vector< std::string > argstr =
        Splitter().on('=').trimWhitespace().split(line, 2);

    RET_SM(
        argstr.size() == 2,
        Status::BAD_INPUT,
        "Error in config file \"" << filename << "\" "
                                  << "on line " << lineno
                                  << " is not a valid flag=value pair");

    tFlagIter itr = GetGlobalFlags().find(argstr[0]);
    RET_SM(
        itr != GetGlobalFlags().end(),
        Status::BAD_INPUT,
        "Unknown flag: " << argstr[0] << " @ line " << lineno);

    iFlagBase *pFlag = itr->second;
    RET_SM(
        pFlag->fromString(TrimQuotes(argstr[1])),
        Status::BAD_INPUT,
        "Invalid flag value for " << argstr[0] << " at line " << lineno
                                  << ". can't parse: " << argstr[1]);

    lineno++;
  }
  return Status::ok();
}
开发者ID:kulseran,项目名称:FISHY,代码行数:57,代码来源:config.cpp

示例13: BOOST_TEST_MESSAGE

void InstrumentTest::testObservable() {

    BOOST_TEST_MESSAGE("Testing observability of instruments...");

    boost::shared_ptr<SimpleQuote> me1(new SimpleQuote(0.0));
    RelinkableHandle<Quote> h(me1);
    boost::shared_ptr<Instrument> s(new Stock(h));

    Flag f;
    f.registerWith(s);
    
    s->NPV();
    me1->setValue(3.14);
    if (!f.isUp())
        BOOST_FAIL("Observer was not notified of instrument change");
    
    s->NPV();
    f.lower();
    boost::shared_ptr<SimpleQuote> me2(new SimpleQuote(0.0));
    h.linkTo(me2);
    if (!f.isUp())
        BOOST_FAIL("Observer was not notified of instrument change");

    f.lower();
    s->freeze();
    s->NPV();
    me2->setValue(2.71);
    if (f.isUp())
        BOOST_FAIL("Observer was notified of frozen instrument change");
    s->NPV();
    s->unfreeze();
    if (!f.isUp())
        BOOST_FAIL("Observer was not notified of instrument change");
}
开发者ID:NicholasBertocchi,项目名称:QuantLib,代码行数:34,代码来源:instruments.cpp

示例14: print_flag

// Implementation of "printflag" command
// See also: PrintVMFlagsDCmd class
static jint print_flag(AttachOperation* op, outputStream* out) {
  const char* name = NULL;
  if ((name = op->arg(0)) == NULL) {
    out->print_cr("flag name is missing");
    return JNI_ERR;
  }
  Flag* f = Flag::find_flag((char*)name, strlen(name));
  if (f) {
    f->print_as_flag(out);
    out->print_cr("");
  } else {
    out->print_cr("no such flag '%s'", name);
  }
  return JNI_OK;
}
开发者ID:641252154,项目名称:HotSpot-JVM-Linux-x86-Research,代码行数:17,代码来源:attachListener.cpp

示例15:

	bool NE_DLL NEDebugManager::Flag::operator==(const Flag& source) const
	{
		if(this == &source) return true;
		if(getFlag() != source.getFlag()) return false;

		return true;
	}
开发者ID:kniz,项目名称:World,代码行数:7,代码来源:Flag.cpp


注:本文中的Flag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。