本文整理汇总了C++中broadcast函数的典型用法代码示例。如果您正苦于以下问题:C++ broadcast函数的具体用法?C++ broadcast怎么用?C++ broadcast使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了broadcast函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:morsya,项目名称:omim,代码行数:13,代码来源:nv_event_queue.cpp
示例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());
}
开发者ID:JBouron,项目名称:polybar,代码行数:13,代码来源:network.cpp
示例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();
}
开发者ID:Yuzhen11,项目名称:IOpregel-exp,代码行数:22,代码来源:Hashmin_recoded.cpp
示例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;
}
}
开发者ID:hubertwe,项目名称:BusLab,代码行数:13,代码来源:server.hpp
示例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);
}
开发者ID:emarschner,项目名称:playround,代码行数:13,代码来源:Network.cpp
示例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;
}
开发者ID:coredumped,项目名称:X-VR2,代码行数:13,代码来源:Socket.cpp
示例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;
}
}
开发者ID:ptkila,项目名称:cowichan,代码行数:51,代码来源:life.cpp
示例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";
}
开发者ID:amireh,项目名称:Phantom,代码行数:50,代码来源:instance.cpp
示例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);
}
开发者ID:Kafei59,项目名称:epitech-projects,代码行数:23,代码来源:egg.c
示例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;
}
开发者ID:Emma-uestc,项目名称:meep,代码行数:14,代码来源:step.cpp
示例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;
}
开发者ID:BrendanParks,项目名称:VLAN,代码行数:14,代码来源:linkstate.c
示例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;
}
}
开发者ID:rsaxvc,项目名称:multiscope,代码行数:50,代码来源:hdlc16.cpp
示例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;
}
开发者ID:jihednasr,项目名称:xsim,代码行数:50,代码来源:test_poisson.c
示例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;
}
开发者ID:neattools,项目名称:neattools,代码行数:14,代码来源:JMousePosObj.cpp
示例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;
}
开发者ID:philippedeswert,项目名称:dsme,代码行数:28,代码来源:state.c
示例16: max
void JBSubObj::putResult() {
JBlock ov = value;
int dest = end;
int sz = block.size();
if (sz > 0) {
begin = max(0, min(sz-1, begin));
if (inputSet(IN_END).last()) {
if (dest < 0) dest = sz;
else dest = max(begin, min(sz, dest));
} else dest = begin+1;
value = block(begin, dest);
} else value = block;
if (value != ov) broadcast(0);
}
开发者ID:neattools,项目名称:neattools,代码行数:14,代码来源:JBSubObj.cpp
示例17: time
void Monster::diePermCrt() {
std::map<int, crlasttime>::iterator it;
crlasttime* crtm=0;
Monster *temp_mob=0;
UniqueRoom *room=0;
char perm[80];
long t = time(0);
int i=0;
strcpy(perm,getCName());
if(!inUniqueRoom())
return;
room = getUniqueRoomParent();
for(it = room->permMonsters.begin(); it != room->permMonsters.end() ; it++) {
crtm = &(*it).second;
if(!crtm->cr.id)
continue;
if(crtm->ltime + crtm->interval > t)
continue;
if(!loadMonster(crtm->cr, &temp_mob))
continue;
if(temp_mob->getName() == getName()) {
crtm->ltime = t;
free_crt(temp_mob);
break;
}
free_crt(temp_mob);
}
if(flagIsSet(M_DEATH_SCENE) && !flagIsSet(M_FOLLOW_ATTACKER)) {
int fd,n;
char tmp[2048], file[80],pName[80];
strcpy(pName, getCName());
for(i=0; pName[i]; i++)
if(pName[i] == ' ')
pName[i] = '_';
sprintf(file,"%s/%s_%d", Path::Desc, pName, level);
fd = open(file,O_RDONLY,0);
if(fd) {
n = read(fd,tmp,2048);
tmp[n] = 0;
broadcast(nullptr, getRoomParent(), "\n%s", tmp);
}
close(fd);
}
}
开发者ID:RealmsMud,项目名称:RealmsCode,代码行数:50,代码来源:creature.cpp
示例18: beginSynchronized
void
CondVarImpl::syncThreads()
{
//! Lock condition variable lock
beginSynchronized();
int rc = 0;
//! count threads
if(_count == 0xFFFFFFFF)
_count = 0;
else
{
_count++;
}
if(_count >= _maxThreads - 1)
{
//! Set to highest value before broadcasting
_count = 0xFFFFFFFF;
//! Unblock all waiting threads
#ifdef _WIN32
rc = broadcast();
if(rc == 0)
printf("Problem while calling broadcast\n");
#else
rc = pthread_cond_broadcast(&_condVar);
PRINT_ERROR_MSG(rc, "Problem while calling pthread_cond_broadcast()");
#endif // _WIN32
}
else
{
//! Block on a condition variable
#ifdef _WIN32
wait();
#else
if(_count < _maxThreads - 1)
{
rc = pthread_cond_wait(&_condVar, &_condVarLock);
PRINT_ERROR_MSG(rc, "Problem while calling pthread_cond_wait()");
}
#endif // _WIN32
}
//! Unlock condition variable lock
endSynchronized();
}
开发者ID:CryDevPortal,项目名称:amd-app-sdk-fixes,代码行数:50,代码来源:SDKThread.cpp
示例19: ev_handler
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
switch (ev) {
case MG_EV_WEBSOCKET_HANDSHAKE_DONE: {
/* New websocket connection. Tell everybody. */
broadcast(nc, mg_mk_str("++ joined"));
break;
}
case MG_EV_WEBSOCKET_FRAME: {
struct websocket_message *wm = (struct websocket_message *) ev_data;
/* New websocket message. Tell everybody. */
struct mg_str d = {(char *) wm->data, wm->size};
broadcast(nc, d);
break;
}
case MG_EV_CLOSE: {
/* Disconnect. Tell everybody. */
if (is_websocket(nc)) {
broadcast(nc, mg_mk_str("-- left"));
}
break;
}
}
}
开发者ID:gavinying,项目名称:mongoose,代码行数:23,代码来源:websocket_chat.c
示例20: broadcast
/**************************************************************
* Take a good hard look at how much punishment we've taken, *
* and get out if it's just too much to take! *
**************************************************************/
int Pilot::damage_check()
{
if (flight->mods.battle_damage > 0)
{
if (flight->mods.battle_damage >= flight->specs->max_damage)
{
if (functioning)
{
broadcast("Ejecting!",6,getAffiliation(),NULL);
sound_off("takingfire");
sound_off("takingflak");
sound_off("heavydamage");
sound_on("eject",getAffiliation());
dbg = "EJECT";
functioning = 0;
set_target(NULL);
SetDeath(1);
}
return (1);
}
else
{
if (flight->mods.battle_damage > new_damage)
{
new_damage = flight->mods.battle_damage;
float d1 = ((float)new_damage) / ((float)flight->specs->max_damage);
if (target_obj->who_got_me != NULL && target_obj->who_got_me->getType() == GROUND_UNIT_T)
{
brdcst(sbrPRIORITY_REGULAR,getAffiliation(),"Taking flak: %3.0f%%%%",d1 * 100.0);
sound_on("takingflak",getAffiliation());
}
else
{
if (d1 >= 0.75)
{
brdcst(sbrPRIORITY_REGULAR,getAffiliation(),"Heavy damage: %3.0f%%%%!",d1 * 100.0);
sound_on("heavydamage",getAffiliation());
}
else
{
brdcst(sbrPRIORITY_REGULAR,getAffiliation(),"Taking fire %3.0f%%%%",d1 * 100.0);
sound_on("takingfire",getAffiliation());
}
}
}
}
}
return (0);
}
开发者ID:zear,项目名称:sabre,代码行数:53,代码来源:pilot.C
注:本文中的broadcast函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论