本文整理汇总了C++中WAIT函数的典型用法代码示例。如果您正苦于以下问题:C++ WAIT函数的具体用法?C++ WAIT怎么用?C++ WAIT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WAIT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isc__task_beginexclusive
ISC_TASKFUNC_SCOPE isc_result_t
isc__task_beginexclusive(isc_task_t *task0) {
#ifdef USE_WORKER_THREADS
isc__task_t *task = (isc__task_t *)task0;
isc__taskmgr_t *manager = task->manager;
REQUIRE(task->state == task_state_running);
LOCK(&manager->lock);
if (manager->exclusive_requested) {
UNLOCK(&manager->lock);
return (ISC_R_LOCKBUSY);
}
manager->exclusive_requested = ISC_TRUE;
while (manager->tasks_running > 1) {
WAIT(&manager->exclusive_granted, &manager->lock);
}
UNLOCK(&manager->lock);
#else
UNUSED(task0);
#endif
return (ISC_R_SUCCESS);
}
示例2: main
int main(){
/*===Start===*/
servo_setup();
printf("Press any button to start");
WAIT(a_button()||b_button()||c_button());
//printf("waiting 2 seconds"); sleep(2);
/*===Gold One===*/
servo_drive_pos();
squareup(-80,1);
forward(35,100);
squareup(80,1);
get_gold();
/*===Score Gold===*/
back(17,80);
score_gold();
/*===Reposition===*/
left(90,0,100);
squareup(80,3);
/*===Botguy===*/
thread going=thread_create(arms_down_slow);
thread_start(going);
back(20,100);
back(30,100);
/*set_servo_position(ARM,ARM_UP);
msleep(500);
forward(34+5,100);
back(5);
set_servo_position(ARM,ARM_DOWN);
msleep(500);*/
/*===Tail===*/
disable_servos();
ao();
}
示例3: run
static isc_threadresult_t
#ifdef _WIN32 /* XXXDCL */
WINAPI
#endif
run(void *uap) {
isc_timermgr_t *manager = uap;
isc_time_t now;
isc_result_t result;
LOCK(&manager->lock);
while (!manager->done) {
TIME_NOW(&now);
XTRACETIME(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
ISC_MSG_RUNNING,
"running"), now);
dispatch(manager, &now);
if (manager->nscheduled > 0) {
XTRACETIME2(isc_msgcat_get(isc_msgcat,
ISC_MSGSET_GENERAL,
ISC_MSG_WAITUNTIL,
"waituntil"),
manager->due, now);
result = WAITUNTIL(&manager->wakeup, &manager->lock, &manager->due);
INSIST(result == ISC_R_SUCCESS ||
result == ISC_R_TIMEDOUT);
} else {
XTRACETIME(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
ISC_MSG_WAIT, "wait"), now);
WAIT(&manager->wakeup, &manager->lock);
}
XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER,
ISC_MSG_WAKEUP, "wakeup"));
}
UNLOCK(&manager->lock);
return ((isc_threadresult_t)0);
}
示例4: process_skinchanger_detail_menu
bool process_skinchanger_detail_menu()
{
if (!skinchanger_used)
{
set_status_text("Please apply a skin first");
return false;
}
DWORD waitTime = 150;
int foundTextures = 0;
std::vector<std::string> menuCaptions;
std::vector<int> menuValues;
DWORD model = GAMEPLAY::GET_HASH_KEY((char *)chosenSkinName.c_str());
if (STREAMING::IS_MODEL_IN_CDIMAGE(model) && STREAMING::IS_MODEL_VALID(model))
{
STREAMING::REQUEST_MODEL(model);
while (!STREAMING::HAS_MODEL_LOADED(model)) WAIT(0);
for (int i = 0; i < 15; i++)
{
for (int j = 0; j < 1000; j++)
{
int drawable = rand() % 10;
int texture = rand() % 10;
if (PED::IS_PED_COMPONENT_VARIATION_VALID(PLAYER::PLAYER_PED_ID(), i, drawable, texture))
{
std::string itemText = getSkinDetailAttribDescription(i);
menuCaptions.push_back(itemText);
menuValues.push_back(i);
break;
}
}
}
STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(model);
}
return drawGenericMenu<int>(menuCaptions, menuValues, skinDetailMenuIndex, "Skin Details", onconfirm_skinchanger_detail_menu, onhighlight_skinchanger_detail_menu, NULL);
}
示例5: animate
boolean animate(char* data, int len) {
for (int loop = 0; loop < 10; loop++) {
for (int i = 0; i < len - 8; i++) {
timenobtn = 0;
// setMatrix2(data + i);
CLS(1);
for (int k = 0; k < 8; k++)
buf[k] = data[k + i];
FLUSH();
// if (uart0_test())
for (int j = 0; j < 90; j++) {
WAIT(1);
if (ux_btn()) {
return 1;
}
}
}
// break;
}
deepPowerDown();
return 1;
}
示例6: process_skinchanger_drawable_menu
bool process_skinchanger_drawable_menu(std::string caption)
{
DWORD waitTime = 150;
int foundTextures = 0;
std::vector<std::string> menuCaptions;
std::vector<int> menuValues;
DWORD model = GAMEPLAY::GET_HASH_KEY((char *)chosenSkinName.c_str());
if (STREAMING::IS_MODEL_IN_CDIMAGE(model) && STREAMING::IS_MODEL_VALID(model))
{
STREAMING::REQUEST_MODEL(model);
while (!STREAMING::HAS_MODEL_LOADED(model)) WAIT(0);
for (int i = 0; i < 100; i++)
{
int drawable = i;
for (int j = 0; j < 100; j++)
{
int texture = j;
if (PED::IS_PED_COMPONENT_VARIATION_VALID(PLAYER::PLAYER_PED_ID(), skinDetailMenuValue, drawable, texture))
{
std::ostringstream ss;
ss << "Drawable #" << std::to_string(drawable);
menuCaptions.push_back(ss.str());
menuValues.push_back(drawable);
break;
}
}
}
STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(model);
}
std::ostringstream ss;
ss << caption << " Drawables";
return drawGenericMenu<int>(menuCaptions, menuValues, skinDrawableMenuIndex, ss.str(), onconfirm_skinchanger_drawable_menu, onhighlight_skinchanger_drawable_menu, onexit_skinchanger_drawable_menu);
}
示例7: onhighlight_skinchanger_drawable_menu
void onhighlight_skinchanger_drawable_menu(int selection, std::string caption, int value)
{
//TODO: remove these two
skinDrawableMenuIndex = selection;
skinDrawableMenuValue = value;
int texture;
if (value == skinDrawableMenuValue && skinTextureMenuValue != -1)
{
texture = skinTextureMenuValue;
}
else
{
texture = findFirstValidPedTexture(value);
}
if (PED::IS_PED_COMPONENT_VARIATION_VALID(PLAYER::PLAYER_PED_ID(), skinDetailMenuValue, value, texture))
{
PED::SET_PED_COMPONENT_VARIATION(PLAYER::PLAYER_PED_ID(), skinDetailMenuValue, value, texture, 0);
}
skinchanger_used = true;
WAIT(100);
}
示例8: wr_flush
/* Call only when writer mutex and buffer mutex are locked */
static bool_t wr_flush(Pipe_st *st)
{
bool_t empty;
do {
empty = (st->wrp==st->rdp);
if (!empty) {
if (!st->rd_open) {
return False; /* Reader closed, not all data flushed */
}
/* The reader might be stalled; if it is, give it a kick */
if (st->waiting) {
st->waiting=False;
SIGNAL(&st->cv);
}
/* Now we wait to see what happens. */
st->waiting=True;
WAIT(&st->mu, &st->cv);
}
} while (!empty);
return True;
}
示例9: strcpy
KernelFile::KernelFile(char *fname, char mode, Entry entry, Drive *drive) {
strcpy(this->fname, fname);
this->mode = mode;
this->entry = entry;
this->drive = drive;
cluster = new DataCluster(drive);
switch (mode) {
case 'r': pointer = 0;
break;
case 'w': pointer = 0;
truncate();
break;
case 'a': pointer = entry.size;
seek(pointer);
break;
}
WAIT(numOfFilesMutex);
drive->incNumOfFiles();
SIGNAL(numOfFilesMutex);
}
示例10: get_ground_height_at_position
/**
* Many props don't play nicely with PLACE_OBJECT_ON_GROUND_PROPERLY.
* Therefore we use one that is known to work properly to determine
* the height of the ground, and therefore the position for the other
* prop, by spawning one and then deleting it.
*/
bool get_ground_height_at_position(Vector3 coords, float* result)
{
Hash propHash = GAMEPLAY::GET_HASH_KEY("prop_veg_crop_03_cab");
STREAMING::REQUEST_MODEL(propHash);
DWORD now = GetTickCount();
while (!STREAMING::HAS_MODEL_LOADED(propHash) && GetTickCount() < now + 5000)
{
make_periodic_feature_call();
WAIT(0);
}
if (!STREAMING::HAS_MODEL_LOADED(propHash))
{
return false;
}
Vector3 minDimens;
Vector3 maxDimens;
GAMEPLAY::GET_MODEL_DIMENSIONS(propHash, &minDimens, &maxDimens);
Object obj = OBJECT::CREATE_OBJECT_NO_OFFSET(propHash, coords.x, coords.y, coords.z, creationParam1, creationParam2, creationParam3);
ENTITY::SET_ENTITY_VISIBLE(obj, false);
OBJECT::PLACE_OBJECT_ON_GROUND_PROPERLY(obj);
Vector3 objLocation = ENTITY::GET_ENTITY_COORDS(obj, 0);
float objHeight = ENTITY::GET_ENTITY_HEIGHT(obj, objLocation.x, objLocation.y, objLocation.z, 1, 0);
*result = objLocation.z - objHeight;
if (minDimens.z < 0)
{
*result += minDimens.z;
}
OBJECT::DELETE_OBJECT(&obj);
return true;
}
示例11: LoadScript
bool LoadScript( const char *script )
{
if ( !IS_STRING_NULL(script) )
{
if ( DOES_SCRIPT_EXIST(script) )
{
if ( GET_NUMBER_OF_INSTANCES_OF_STREAMED_SCRIPT(script) > 0 )
{
TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME(script);
}
else
{
TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME(script);
UNPAUSE_GAME();
REQUEST_SCRIPT(script);
while ( !HAS_SCRIPT_LOADED(script) ) WAIT(100);
START_NEW_SCRIPT(script, 1024);
MARK_SCRIPT_AS_NO_LONGER_NEEDED(script);
return TRUE;
}
}
}
return FALSE;
}
示例12: main
void main()
{
set_periodic_feature_call(updateStuff);
featurePlayerBlips = config->get_trainer_config()->setting_player_blips;
featurePlayerHeadDisplay = config->get_trainer_config()->setting_player_head_display;
featurePlayerBlipCone = config->get_trainer_config()->setting_player_blip_cone;
featurePlayerNotifications = config->get_trainer_config()->setting_player_notifications;
featureShowVoiceChatSpeaker = config->get_trainer_config()->setting_show_voice_chat_speaker;
while (true)
{
if (is_menu_showing())
{
menu_beep(0);
process_main_menu();
set_menu_showing(false);
}
updateStuff();
WAIT(0);
}
}
示例13: WAIT
/**
* Pomeranje tekuce pozicije u fajlu
*/
char KernelFile::seek(BytesCnt bytesCnt) {
if (getFileSize() == 0) return 0; // ako je prazan fajl
if (bytesCnt > getFileSize()) return 0; // ako premasuje velicinu
WAIT(partitionAccessMutex);
pointer = bytesCnt;
if ('r' != mode) cluster->writeToDisk();
BytesCnt i = 0;
ClusterNo clusterToFetch = entry.firstCluster;
do {
cluster->setClusterNo(clusterToFetch);
cluster->readFromDisk();
clusterToFetch = cluster->getNextCluster();
i += EfficientClusterSize;
} while (i < pointer);
SIGNAL(partitionAccessMutex);
return 1;
}
示例14: twi_read
uchar twi_read(uchar W_ADDRESS)
{
uchar temp;
START(); //TWI启动
WAIT();
if (SATUS()!=_START)
return TRUE;
TWI_WRITE(W_MPU6050_ADDR); //写 MPU6050地址和写方式
WAIT();
if (SATUS()!=MT_SLA_ACK)
return TRUE;
TWI_WRITE(W_ADDRESS); //写 MPU6050相应寄存器地址
WAIT();
if (SATUS()!=MT_DATA_ACK)
return TRUE;
START(); //TWI重新启动
WAIT();
if (SATUS()!=RE_START)
return TRUE;
TWI_WRITE(R_MPU6050_ADDR); //写 MPU6050地址和读方式
WAIT();
if(SATUS()!=MR_SLA_ACK)
return TRUE;
TWI_READ(); //启动主TWI读方式
WAIT();
if(SATUS()!=MR_DATA_NOACK)//读完一个数停止接收数据 ,主机接收到不再接收应答信号 ,如果继续接收到应答信号
return TRUE; //说明主机继续接收数据则为错误
temp=TWDR; //读取 TWI接收数据
STOP(); //TWI停止
return temp;
}
示例15: pload
int
pload (int tbl)
{
int c = 0, i, status;
if (verbose > 0)
{
fprintf (stderr, "Starting %d children to load %s",
children, tdefs[tbl].comment);
}
for (c = 0; c < children; c++)
{
pids[c] = SPAWN ();
if (pids[c] == -1)
{
perror ("Child loader not created");
kill_load ();
exit (-1);
}
else if (pids[c] == 0) /* CHILD */
{
SET_HANDLER (stop_proc);
verbose = 0;
partial (tbl, c+1);
exit (0);
}
else if (verbose > 0) /* PARENT */
fprintf (stderr, ".");
}
if (verbose > 0)
fprintf (stderr, "waiting...");
c = children;
while (c)
{
i = WAIT (&status, pids[c - 1]);
if (i == -1 && children)
{
if (errno == ECHILD)
fprintf (stderr, "\nCould not wait on pid %d\n", pids[c - 1]);
else if (errno == EINTR)
fprintf (stderr, "\nProcess %d stopped abnormally\n", pids[c - 1]);
else if (errno == EINVAL)
fprintf (stderr, "\nProgram bug\n");
}
if (! WIFEXITED(status)) {
(void) fprintf(stderr, "\nProcess %d: ", i);
if (WIFSIGNALED(status)) {
(void) fprintf(stderr, "rcvd signal %d\n",
WTERMSIG(status));
} else if (WIFSTOPPED(status)) {
(void) fprintf(stderr, "stopped, signal %d\n",
WSTOPSIG(status));
}
}
c--;
}
if (verbose > 0)
fprintf (stderr, "done\n");
return (0);
}