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


C++ thread_t类代码示例

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


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

示例1: find_node

int find_node(thread_t& t, xg::XG::ThreadMapping node, int hint) {
  if(hint > t.size()) {
    hint = (t.size() - 1)/2;
  }
  if(t[hint].node_id == node.node_id && t[hint].is_reverse == node.is_reverse) {
    return hint;
  } else {
    int above = t.size() - hint;
    int bound = max(above,hint);
    int search_up = hint;
    int search_down = hint;
    for(int i = 1; i < bound; i++) {
      if(search_up < t.size() - 1) {
        search_up++;
        if(t[search_up].node_id == node.node_id && t[search_up].is_reverse == node.is_reverse) {
          return search_up;
        }
      }
      if(search_down > 0) {
        search_down--;
        if(t[search_down].node_id == node.node_id && t[search_down].is_reverse == node.is_reverse) {
          return search_down;
        }
      }
    }
  }
  // wasn't found!
  return -1;
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例2: simple_extend

void rectangle::simple_extend(thread_t& extension, xg::XG& graph, int delta_start = 0, int delta_end = 0) {
  if(extension.size() > 0) {
    xg::XG::ThreadMapping next_node = extension.back();
    int64_t next_side = graph.id_to_rank(next_node.node_id) * 2 + next_node.is_reverse;
    state.current_side = next_side;
  }
  state.range_start -= delta_start;
  state.range_end -= delta_end;
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例3: get_next_J

int rectangle::get_next_J(thread_t& extension, XG& graph) {
  if(extension.size() == 1) {
    return get_next_J(extension.back(), graph);
  } else {
    xg::XG::ThreadMapping second_last_node = extension.end()[-2];
    state.current_side = graph.id_to_rank(second_last_node.node_id) * 2 + second_last_node.is_reverse;
    extend(extension.back(), graph);
    J = state.count();
    return state.count();
  }
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例4:

void zmq::thread_ctx_t::start_thread (thread_t &thread_,
                                      thread_fn *tfn_,
                                      void *arg_) const
{
    static unsigned int nthreads_started = 0;

    thread_.setSchedulingParameters (_thread_priority, _thread_sched_policy,
                                     _thread_affinity_cpus);
    thread_.start (tfn_, arg_);
#ifndef ZMQ_HAVE_ANDROID
    std::ostringstream s;
    if (!_thread_name_prefix.empty ())
        s << _thread_name_prefix << "/";
    s << "ZMQbg/" << nthreads_started;
    thread_.setThreadName (s.str ().c_str ());
#endif
    nthreads_started++;
}
开发者ID:pijyoi,项目名称:libzmq,代码行数:18,代码来源:ctx.cpp

示例5: check_if_thread_t_broken

bool check_if_thread_t_broken(const thread_t& t, XG& graph) {
  bool broken = false;
  XG::ThreadMapping current_node = t[0];
  for(int i = 1; i < t.size(); i++) {
    XG::ThreadMapping next_node = t[i];
    bool edge_exists = check_for_edges(current_node.node_id, current_node.is_reverse,
            next_node.node_id, next_node.is_reverse, graph);
    if(!edge_exists) {
      broken = true;
      break;
    }
    current_node = next_node;
  }
  return broken;
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例6:

haplo_d::haplo_d(const thread_t& t, XG& graph) {
  rectangle rect;
  rect.J = rect.get_next_J(t[0],graph);
  // At the leftmost node there is only one strip, so I = J
  rect.I = rect.J;
  int last_height = rect.J;
  cs.push_back(cross_section(rect.J,0,t[0]));
  cs.back().S.push_back(rect);
  int width = 0;
  int new_height;
  bool add_rectangle;
  bool add_A;
  for(int i = 1; i < t.size(); i++) {
    // Count the number of base pairs since the last entry or exit node
    width += graph.node_length(t[i-1].node_id);
    new_height = graph.node_height(t[i]);
    if(cs.back().S.size() != 0) {
      rect = cs.back().S[0];
      rect.J = rect.get_next_J(t[i],graph); // step this strip forward
      // Did any threads leave?
      if(last_height > rect.J) {
        add_A = 1;
      }
      // Are there any threads here which didn't come from the previous node?
      if(rect.J < new_height) {
        add_rectangle = 1;
        add_A = 1;
      }
      // This is an entry or exit node, add a cross-section to the vector of
      // cross-sections (which corresponds to the "A" set in the theory doc)
      if(add_A) {
        cs.back().width = width;
        width = 0;
        cs.push_back(cross_section(new_height,i,t[i]));
      } else {
        // This isn't a node where anything leaves or joins, let's skip over it
        cs.back().bridge.push_back(t[i]);
        for (size_t a = 0; a < cs.back().S.size(); a++) {
          cs.back().S[a].extend(t[i],graph);
        }
      }
      // This is an entry node; we also need a new rectangle corresponding to the
      // new strip. We need to do this *before* we populate since cross_sections
      // arrange rectangles newest -> oldest
      // NB that add_rectangle implies add_A
      if(add_rectangle) {
        rectangle new_rect;
        new_rect.extend(t[i],graph);
        new_rect.J = new_height;
        cs.back().height = new_rect.J;
        cs.back().S.push_back(new_rect);
        cs.back().S.back().I = new_rect.J - rect.J;
      }
      if(add_A) {
        int b = cs.size()-1;
        if(rect.J > 0) {
          cs[b].S.push_back(rect);
          cs[b].S.back().prev = 0;
          cs[b-1].S[0].next = cs[b].S.size()-1;
        }
      }
      last_height = new_height;
      add_A = 0;
      add_rectangle = 0;
    } else {
      cs.back().width = width;
      width = 0;
      cs.push_back(cross_section(new_height,i,t[i]));
      if(new_height > 0) {
        rectangle new_rect;
        new_rect.extend(t[i],graph);
        new_rect.J = new_height;
        cs.back().height = new_rect.J;
        cs.back().S.push_back(new_rect);
        cs.back().S.back().I = new_rect.J - rect.J;
      }
    }
  }
  if(cs.size() == 1) {
    cs.back().width = width;
  }
  cs.back().width += graph.node_length(t.back().node_id) - 1;
  for(int i = 0; i < cs.size(); i++) {
    tot_width += cs[i].width;
  }
}
开发者ID:,项目名称:,代码行数:86,代码来源:

示例7: initialize_skeleton

void haplo_d::initialize_skeleton(thread_t& t, int start, cross_section& prevAs, xg::XG& graph) {
  assert(cs.size() == 0);
  initialize_skeleton(t, make_pair(start, t.size()-1), prevAs, graph);
}
开发者ID:,项目名称:,代码行数:4,代码来源:

示例8:

void zmq::ctx_t::start_thread (thread_t &thread_, thread_fn *tfn_, void *arg_) const
{
    thread_.start(tfn_, arg_);
    thread_.setSchedulingParameters(thread_priority, thread_sched_policy);
}
开发者ID:5igm4,项目名称:libzmq,代码行数:5,代码来源:ctx.cpp

示例9:

	~delayed_thread() {
		if(m_state == DISMISSED) {
			return;
		}

		trigger();

		if(m_thread.joinable()) {
			m_thread.join();
		}
	}
开发者ID:wonghoifung,项目名称:frog-all,代码行数:11,代码来源:item39.cpp


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