本文整理汇总了C++中broadcast函数的典型用法代码示例。如果您正苦于以下问题:C++ broadcast函数的具体用法?C++ broadcast怎么用?C++ broadcast使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了broadcast函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pthread_mutex_lock
void NVEventQueue::DoneWithEvent(bool ret)
{
// We only care about blockers for now.
// All other events just NOP
pthread_mutex_lock(&m_accessLock);
if (m_blockerState == PROCESSING_BLOCKER)
{
m_blockerReturnVal = ret;
m_blockerState = RETURNED_BLOCKER;
broadcast(&m_blockerSync);
}
pthread_mutex_unlock(&m_accessLock);
}
示例2: while
void network_module::subthread_routine() {
const chrono::milliseconds framerate{m_animation_packetloss->framerate()};
const auto dur = chrono::duration<double>(framerate);
while (running()) {
if (m_connected && m_packetloss) {
broadcast();
}
sleep(dur);
}
m_log.trace("%s: Reached end of network subthread", name());
}
示例3: compute
virtual void compute(VertexID agg_msg, vector<VertexID>& edges)
{
if(step_num()==1)
{
VertexID min = id;
for (int i = 0; i < edges.size(); ++ i)
{
if (min > edges[i]) min = edges[i];
}
value = min;
broadcast(edges);
}
else
{
if (agg_msg < value)
{
value = agg_msg;
broadcast(edges);
}
}
vote_to_halt();
}
示例4: broadcastTextMessageToAll
void broadcastTextMessageToAll(Message& message, ClientDesc client)
{
message.setClientSource(client.descriptor);
if(isClientAbleToBroadcastMessage(client.descriptor))
{
broadcast(message);
}
else
{
std::cout << "Client: " << client.descriptor << " can't broadcast messages due to certificate name restrictions." << std::endl;
}
}
示例5: ps
void Network::sendRoundPadTextMessage(const RoundPad* pad)
{
// Utility data structures
char buffer[1024];
osc::OutboundPacketStream ps(buffer, 1024);
ps << osc::BeginMessage("/object/pad/text")
<< osc::Symbol(pad->getUuid())
<< osc::Symbol(pad->getCommentText()->getText().c_str())
<< osc::EndMessage;
broadcast(ps);
}
示例6: broadcast
bool Socket::broadcast(bool enabled){
bool ret;
int val;
ret = broadcast();
if(enabled == false){
val = 0;
}
else{
val = 1;
}
setsockopt(SOL_SOCKET, SO_BROADCAST, (const void *)&val, (socklen_t)sizeof(int));
return ret;
}
示例7: get_block
void CowichanMPI::life(BoolMatrix matrixIn, BoolMatrix matrixOut)
{
int i; // iteration index
index_t r; // row index
int alive; // number alive
index_t lo, hi; // work controls
index_t rlo, rhi; // for broadcast
bool work; // useful work to do?
int is_alive = 1; // some cells still alive?
BoolMatrix m_tmp; // tmp pointer
// work
work = get_block (world, 0, nr, &lo, &hi);
for (i = 0; (i < lifeIterations) && (is_alive > 0); i++) {
// reset alive neighbour count
alive = 0;
// count neighbours and fill new matrix
if (work) {
for (r = lo; r < hi; r++) {
for (index_t c = 0; c < nc; ++c) {
index_t count = sumNeighbours(matrixIn, r, c, nr, nc);
if (count == 3 || ((count == 2) && MATRIX_RECT(matrixIn, r, c))) {
MATRIX_RECT(matrixOut, r, c) = true;
++alive;
} else {
MATRIX_RECT(matrixOut, r, c) = false;
}
}
}
}
// broadcast matrix
for (r = 0; r < world.size (); r++) {
if (get_block (world, 0, nr, &rlo, &rhi, r)) {
broadcast (world, &MATRIX_RECT(matrixOut, rlo, 0),
(int)((rhi - rlo) * nc), (int)r);
}
}
// is_alive is maximum of local alive's
all_reduce (world, alive, is_alive, mpi::maximum<int>());
// swap matrices (ping-pong)
m_tmp = matrixIn;
matrixIn = matrixOut;
matrixOut = m_tmp;
}
}
示例8: catch
void instance::on_charge(const Event& evt) {
// verify the existence of the unit and that its the owner's turn
if (!evt.hasProperty("UID"))
return;
bool valid = true;
Unit *_unit = 0;
try {
_unit = active_puppet_->getUnit(convertTo<int>(evt.getProperty("UID")));
} catch (invalid_uid &e) {
valid = false;
}
std::cout
<< "attempting to find unit with UID : " << evt.getProperty("UID")
<< " and active puppet " << active_puppet_->getUID() << "#" << active_puppet_->getName()
<< " has: \n";
for (auto unit : active_puppet_->getUnits())
std::cout << "\t+" << unit->getUID() << "#" << unit->getName() << "\n";
if (!valid) {
log_->errorStream() << "invalid charge attempt, uid: " << evt.getProperty("UID");
return;
}
//assert(valid); // __DEBUG__
// make sure the unit is not resting
valid = !_unit->isResting();
assert(valid); // __DEBUG__
if (_unit->getBaseAP() <= 0)
return;
// finally make sure the unit has not already been flagged for attacking
// (this really shouldn't happen)
if (!attackers_.empty())
for (Unit* unit : attackers_)
assert(unit != _unit);
attackers_.push_back(_unit);
Event e(EventUID::Charge, EventFeedback::Ok);
e.setProperty("UID", _unit->getUID());
broadcast(e);
log_->debugStream() << _unit->getUID() << _unit->getName() << " is charging";
}
示例9: asprintf
t_client *check_egg(t_server *server, t_client *client)
{
t_client *egg;
char *s;
if ((egg = get_client_egg_by_team(server->clients, client->team)) != NULL)
{
asprintf(&s, "eht #%d\n", egg->socket);
broadcast(server->clients, s, FD_GRAPHIC);
free(s);
asprintf(&s, "ebo #%d\n", egg->socket);
broadcast(server->clients, s, FD_GRAPHIC);
free(s);
client->player = egg->player;
server->clients = pop_client(server->clients, egg->socket);
}
else
create_player(server, client);
return (server->clients);
}
示例10: broadcast
double fields_chunk::peek_field(component c, const vec &where) {
double w[8];
ivec ilocs[8];
gv.interpolate(c,where, ilocs, w);
if (gv.contains(ilocs[0]) && f[c][0]) {
double hello = 0.0;
if (is_mine()) hello = f[c][0][gv.index(c,ilocs[0])];
broadcast(n_proc(), &hello, 1);
return hello;
}
//abort("Got no such %s field at %g %g!\n",
// component_name(c), gv[ilocs[0]].x(), gv[ilocs[0]].y());
return 0.0;
}
示例11: flood_linkstate
int flood_linkstate(struct routes* route_list, struct memberList* member_list) {
//lock here
pthread_mutex_lock(&(member_list->lock));
struct AddressInfo source;
struct linkstate_packet* lstate_pack;
create_linkstate_packet(member_list, &source, lstate_pack);
broadcast(route_list, lstate_pack);
pthread_mutex_unlock(&(member_list->lock));
return 0;
}
示例12: assert
void hdlc16::insert_bit( bool bit )
{
assert( bit == 0 || bit == 1 );
last_8_bits = ( last_8_bits << 1 ) | ( bit & 1 );
if( num_contig_ones == 5 && bit == 0 )
{
/*skip stuffed bit*/
}
else
{
if( bitlocked )
{
bitbuf.push_back( bit );
if( bitbuf.size() > 24 )
{
//only insert from 24 bits back
//this skips the frame CRC(16bit),
//and skips the end framer byte(8bit)
crc.insert( bitbuf[ bitbuf.size() - 25 ] );
}
}
if( valid_frame() )
{
frames::frame frame = emit_frame();
frames::buffer buffer;
buffer.push_back( frame );
broadcast( buffer );
}
if( last_8_bits == HDLC_FRAMER )
{
bitbuf.clear();
bitlocked = true;
}
}
if( bit == 1 )
{
num_contig_ones++;
}
else
{
num_contig_ones = 0;
}
}
示例13: sc_son_body_model1
void sc_son_body_model1(xsim_t *xsim, int node_id)
{
/* Initialize xsim */
xsim_node_t *node = NULL;
xsim_msg_list_t **to_send = NULL;
sim_time next_time_for_resource = 0;
sim_time last_time_broadcast = 0;
int stabilized = 0;
xsim_time_model_init_son_body(xsim, node_id, &node, &to_send);
next_time_for_resource = is.simulation_time;
/* global measure */
xsim_perf_begin_global_measure(global_processus_time, CLOCK_PROC);
xsim_perf_begin_global_measure(global_simulation_time, CLOCK_OTHERS);
/*
* Body here
*/
while (node->current_time < (unsigned int) is.simulation_time) {
/* simulate the components of the node */
if (xsim_time_model_simulate_composant(node, to_send, &next_time_for_resource,
&stabilized) == END_OF_SIMULATION)
goto end_of_simulation;
/* update the time if possible */
if (xsim_update_local_time_if_possible(node, stabilized, next_time_for_resource) == 1) {
if ((last_time_broadcast + TIME_PERIOD >= node->current_time) || (last_time_broadcast == 0)) {
broadcast(&node->msg_box->mark, node->iface[0], xsim_null_msg);
last_time_broadcast = node->current_time;
}
if (node->current_time > next_time_for_resource) {
EMSG("<%d> (%"PRIu64" t) Error: jump above the next time the resource should work: %"PRIu64"t\n",
node->node_id, node->current_time, next_time_for_resource);
}
if (node->current_time == next_time_for_resource)
resource_wake_up();
}
}
end_of_simulation:
/* global measure */
xsim_perf_end_global_measure(global_processus_time, CLOCK_PROC);
xsim_perf_end_global_measure(global_simulation_time, CLOCK_OTHERS);
xsim_time_model_end_of_simulation(node, to_send, is.measures_output);
return;
}
示例14: switch
boolean JMousePosObj::globalMouseMove(JEvent& e, int x, int y) {
switch (type) {
case XPOS: {
value = x*mask/(JComponent::theRootWindow->width-1);
break;
}
case YPOS: {
value = y*mask/(JComponent::theRootWindow->height-1);
break;
}
}
broadcast(0);
return true;
}
示例15: change_state
/**
* This function sends a message to clients to notify about state change.
* SAVE_DATA message is also sent when going down.
* @param state State that is being activated
*/
static void change_state(dsme_state_t new_state)
{
if (new_state == DSME_STATE_SHUTDOWN ||
new_state == DSME_STATE_ACTDEAD ||
new_state == DSME_STATE_REBOOT)
{
DSM_MSGTYPE_SAVE_DATA_IND save_msg =
DSME_MSG_INIT(DSM_MSGTYPE_SAVE_DATA_IND);
dsme_log(LOG_DEBUG, PFIX"sending SAVE_DATA");
broadcast(&save_msg);
}
DSM_MSGTYPE_STATE_CHANGE_IND ind_msg =
DSME_MSG_INIT(DSM_MSGTYPE_STATE_CHANGE_IND);
ind_msg.state = new_state;
dsme_log(LOG_DEBUG, PFIX"STATE_CHANGE_IND sent (%s)", state_name(new_state));
broadcast(&ind_msg);
dsme_log(LOG_NOTICE, PFIX"new state: %s", state_name(new_state));
current_state = new_state;
}