本文整理汇总了C++中queue_init函数的典型用法代码示例。如果您正苦于以下问题:C++ queue_init函数的具体用法?C++ queue_init怎么用?C++ queue_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了queue_init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char const *argv[]) {
UNUSED_ARG(argc);
UNUSED_ARG(argv);
//Create queue
lpqueue * q = queue_init(10);
assert(q != NULL);
//Add 10 elements (fill the queue)
bool success;
unsigned int i;
printf("\nEnqueue... ");
for(i = 0; i < 10; i++) {
printf("%u, ", i);
success = queue_append(q, strings[i], strlen(strings[i]), true);
assert(success == true);
}
//Should be full
success = queue_append(q, strings[1], strlen(strings[1]), true);
assert(success == false);
//Pop 10 elements
void * data;
size_t size;
printf("\nDequeue... ");
for(i = 0; i < 10; i++) {
printf("%u, ", i);
success = queue_pop(q, &data, &size);
assert(success == true);
//Check that they are ok
assert(size = strlen(strings[i]));
assert(memcmp(data, strings[i], size) == 0);
free(data);
}
//Should now be empty
success = queue_pop(q, &data, &size);
assert(success == VALUES_QUEUE_EMPTY);
printf("\nTEST SUCCESSFUL!\n");
return 0;
}
开发者ID:vinaypunrao,项目名称:fds,代码行数:44,代码来源:test_values_queue.c
示例2: main
int main()
{
int ret;
common_data_t common_data;
pthread_t recv_tid;
pthread_t write_tid;
queue_init(&common_data);
ret = init_audio_device(&common_data);
if(ret == -1){
dbg("init audio device error.\n");
exit(1);
}
ret = setup_socket(&common_data);
if(ret == -1){
dbg("setup socket error.\n");
return 0;
}
/* create two threads: socket recv thread and pcm write thread */
ret = pthread_create(&recv_tid, NULL, recv_pcmdata, (void *)&common_data);
if (0 != ret){
dbg("can't create recv_pcmdata thread\n");
}
ret = pthread_create(&write_tid, NULL, write_pcmdata, (void *)&common_data);
if (0 != ret){
dbg("can't create write_thread\n");
}
pthread_join(recv_tid, NULL);
// pthread_join(write_tid, NULL);
close(common_data.client_socket);
close(common_data.server_socket);
//free(g_buf);
snd_pcm_drain(common_data.handle);
snd_pcm_close(common_data.handle);
return 0;
}
开发者ID:pursuitxh,项目名称:audio,代码行数:44,代码来源:audio_ring_buffer.c
示例3: main
int main(void)
{
uint8_t msg;
queue_init();
queue_add(1);
queue_add(2);
queue_add(3);
queue_add(4);
queue_add(5);
queue_add(6);
queue_add(7);
msg = queue_get();
printf("Get %d\n", msg);
msg = queue_get();
printf("Get %d\n", msg);
msg = queue_get();
printf("Get %d\n", msg);
msg = queue_get();
printf("Get %d\n", msg);
msg = queue_get();
printf("Get %d\n", msg);
msg = queue_get();
printf("Get %d\n", msg);
msg = queue_get();
printf("Get %d\n", msg);
printf("Hello World!\n");
return 0;
}
开发者ID:maurillo71,项目名称:queue,代码行数:44,代码来源:main.c
示例4: Convert_NFA_To_DFA
/*
* Build Deterministic Finite Automata from NFA
*/
static void
Convert_NFA_To_DFA (ACSM_STRUCT * acsm)
{
int r, s;
int i;
QUEUE q, *queue = &q;
/* Init a Queue */
queue_init (queue);
/* Add the state 0 transitions 1st */
for (i = 0; i < ALPHABET_SIZE; i++)
{
s = acsm->acsmStateTable[0].NextState[i];
if (s)
{
queue_add (queue, s);
}
}
/* Start building the next layer of transitions */
while (queue_count (queue) > 0)
{
r = queue_remove (queue);
/* State is a branch state */
for (i = 0; i < ALPHABET_SIZE; i++)
{
if ((s = acsm->acsmStateTable[r].NextState[i]) != ACSM_FAIL_STATE)
{
queue_add (queue, s);
}
else
{
acsm->acsmStateTable[r].NextState[i] =
acsm->acsmStateTable[acsm->acsmStateTable[r].FailState].
NextState[i];
}
}
}
/* Clean up the queue */
queue_free (queue);
}
开发者ID:Frank-KunLi,项目名称:l7detect,代码行数:47,代码来源:acsmx.c
示例5: main
int main(void) {
// Разрешить светодиод arduino pro mini.
DDRB |= _BV(DDB5);
timer_init();
uart_async_init();
i2c_init();
queue_init();
init_int0();
// Разрешить прерывания.
sei();
uart_readln(&commands_reciver);
uart_writeln("start");
// Бесконечный цикл с энергосбережением.
for(;;) {
switch(queue_getTask()) {
case DO_REQUEST_RTC_DATA_START : //Установть позицию на регистр 0x0
ds3231_buf[0] = 0;
i2c_send(0xD0, ds3231_buf, 1, &callBackForRequestRtcData);
break;
case DO_REQUEST_RTC_DATA_END : //Читаем 7 байт
i2c_recive(0xD0 + 1, ds3231_buf, 7, &callBackForRequestRtcData);
break;
case DO_TIMER1_OVF :
i2c_init();
//queue_putTask(DO_REQUEST_RTC_DATA_START);
timer1_doing = 0;
break;
case COMMAND_SEND_I2C :
i2c_send(commands_reciver_param1[0], // Адресс.
commands_reciver_param2, // Буфер.
commands_reciver_param3[0], // Количество.
&callBackForSendI2CData);
break;
case COMMAND_RECIVE_I2C :
i2c_recive(commands_reciver_param1[0], // Адресс.
ds3231_buf, // Буфер.
commands_reciver_param3[0], // Количество.
&callBackForReciveI2CData);
break;
default : sleep_mode();
}
}
return 0;
}
开发者ID:serg-admin,项目名称:zs-042,代码行数:44,代码来源:zs-042.c
示例6: main
/* The main function creates the LCD task, registers the edge counter polling interrupt,
* and starts the OS. */
int main(void)
{
int status;
// Initialize components.
lcd_init();
queue_init();
// Create the LCD task.
OSTaskCreateExt(lcd_task,
NULL,
(void *)&lcd_task_stk[TASK_STACKSIZE - 1],
LCD_TASK_PRIORITY,
LCD_TASK_PRIORITY,
lcd_task_stk,
TASK_STACKSIZE,
NULL,
0);
// Create the LCD task.
OSTaskCreateExt(ir_task,
NULL,
(void *)&ir_task_stk[TASK_STACKSIZE - 1],
IR_TASK_PRIORITY,
IR_TASK_PRIORITY,
ir_task_stk,
TASK_STACKSIZE,
NULL,
0);
// Register the IR pushbutton interrupt.
status = alt_ic_isr_register(IR_PUSHBUTTON_IRQ_INTERRUPT_CONTROLLER_ID,
IR_PUSHBUTTON_IRQ,
isr_on_ir_pushbutton,
NULL,
NULL);
// Start.
if (status == OK) {
OSStart();
}
return 0;
}
开发者ID:gongal,项目名称:ARCap,代码行数:46,代码来源:main.c
示例7: prio_sched_init
sched_t* prio_sched_init()
{
sched_t* toReturn = (sched_t*)malloc(sizeof(sched_t));
int i;
assert(toReturn != NULL);
toReturn->sched = malloc(sizeof(prio_sched_t));
for (i = 0; i < LOWEST_PRIO; ++i)
{
SCHED_QUEUE(toReturn)[i] = queue_init();
}
toReturn->add_thread = prio_sched_add_thread;
toReturn->next_thread = prio_sched_next_thread;
toReturn->for_all_threads = prio_sched_for_all_threads;
toReturn->destroy = prio_sched_destroy;
return toReturn;
}
开发者ID:FreifeldRoyi,项目名称:user-level-threads,代码行数:19,代码来源:prio_scheduler.c
示例8: main
int main (int argc, char** argv) {
static const char* usage = "usage: aRead numBlocks";
int numBlocks = 0;
queue_init (&prq);
if (argc == 2)
numBlocks = strtol (argv [1], NULL, 10);
if (argc != 2 || (numBlocks == 0 && errno == EINVAL)) {
printf ("%s\n", usage);
return EXIT_FAILURE;
}
uthread_init (1);
disk_start (interruptServiceRoutine);
run (numBlocks);
printf ("%d\n", sum);
}
开发者ID:wuarthur,项目名称:Schduling,代码行数:19,代码来源:aReadY.c
示例9: int
struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev,
void *drv_priv,
int (*queue_init)(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq))
{
struct v4l2_m2m_ctx *m2m_ctx;
struct v4l2_m2m_queue_ctx *out_q_ctx, *cap_q_ctx;
int ret;
m2m_ctx = kzalloc(sizeof *m2m_ctx, GFP_KERNEL);
if (!m2m_ctx)
return ERR_PTR(-ENOMEM);
m2m_ctx->priv = drv_priv;
m2m_ctx->m2m_dev = m2m_dev;
init_waitqueue_head(&m2m_ctx->finished);
out_q_ctx = &m2m_ctx->out_q_ctx;
cap_q_ctx = &m2m_ctx->cap_q_ctx;
INIT_LIST_HEAD(&out_q_ctx->rdy_queue);
INIT_LIST_HEAD(&cap_q_ctx->rdy_queue);
spin_lock_init(&out_q_ctx->rdy_spinlock);
spin_lock_init(&cap_q_ctx->rdy_spinlock);
INIT_LIST_HEAD(&m2m_ctx->queue);
ret = queue_init(drv_priv, &out_q_ctx->q, &cap_q_ctx->q);
if (ret)
goto err;
/*
* If both queues use same mutex assign it as the common buffer
* queues lock to the m2m context. This lock is used in the
* v4l2_m2m_ioctl_* helpers.
*/
if (out_q_ctx->q.lock == cap_q_ctx->q.lock)
m2m_ctx->q_lock = out_q_ctx->q.lock;
return m2m_ctx;
err:
kfree(m2m_ctx);
return ERR_PTR(ret);
}
开发者ID:mhei,项目名称:linux,代码行数:43,代码来源:v4l2-mem2mem.c
示例10: rate_limit_start
void
rate_limit_start(struct secchan *secchan, const struct settings *s,
struct switch_status *ss, struct rconn *remote)
{
struct rate_limiter *rl;
size_t i;
rl = xcalloc(1, sizeof *rl);
rl->s = s;
rl->remote_rconn = remote;
for (i = 0; i < ARRAY_SIZE(rl->queues); i++) {
queue_init(&rl->queues[i]);
}
rl->last_fill = time_msec();
rl->tokens = s->rate_limit * 100;
switch_status_register_category(ss, "rate-limit",
rate_limit_status_cb, rl);
add_hook(secchan, &rate_limit_hook_class, rl);
}
开发者ID:CPqD,项目名称:of11softswitch,代码行数:19,代码来源:ratelimit.c
示例11: fs_init
ret_code_t fs_init(void)
{
uint16_t lowest_index = 0;
uint16_t lowest_order = 0xFFFF;
uint32_t * current_end = (uint32_t*)FS_PAGE_END_ADDR;
uint32_t num_left = FS_SECTION_VARS_COUNT;
queue_init();
/** Assign pages to registered users, beginning with the ones with the lowest
* order, which will be assigned pages with the lowest memory address. */
do
{
fs_config_t * p_config;
for (uint16_t i = 0; i < FS_SECTION_VARS_COUNT; i++)
{
p_config = FS_SECTION_VARS_GET(i);
// Skip the ones which have the end-address already set.
if (p_config->p_end_addr != NULL)
continue;
if (p_config->page_order < lowest_order)
{
lowest_order = p_config->page_order;
lowest_index = i;
}
}
p_config = FS_SECTION_VARS_GET(lowest_index);
p_config->p_end_addr = current_end;
p_config->p_start_addr = p_config->p_end_addr - (p_config->num_pages * FS_PAGE_SIZE_WORDS);
current_end = p_config->p_start_addr;
lowest_order = 0xFFFF;
} while ( --num_left > 0 );
m_flags |= FS_FLAG_INIT;
return NRF_SUCCESS;
}
开发者ID:CarrieTung,项目名称:mbed,代码行数:43,代码来源:fstorage.c
示例12: wait_queue_unlinkall_nofree
kern_return_t
wait_queue_unlinkall_nofree(
wait_queue_t wq)
{
wait_queue_element_t wq_element;
wait_queue_element_t wq_next_element;
wait_queue_set_t wq_set;
wait_queue_link_t wql;
queue_head_t links_queue_head;
queue_t links = &links_queue_head;
queue_t q;
spl_t s;
if (!wait_queue_is_queue(wq)) {
return KERN_INVALID_ARGUMENT;
}
queue_init(links);
s = splsched();
wait_queue_lock(wq);
q = &wq->wq_queue;
wq_element = (wait_queue_element_t) queue_first(q);
while (!queue_end(q, (queue_entry_t)wq_element)) {
WAIT_QUEUE_ELEMENT_CHECK(wq, wq_element);
wq_next_element = (wait_queue_element_t)
queue_next((queue_t) wq_element);
if (wq_element->wqe_type == WAIT_QUEUE_LINK) {
wql = (wait_queue_link_t)wq_element;
wq_set = wql->wql_setqueue;
wqs_lock(wq_set);
wait_queue_unlink_locked(wq, wq_set, wql);
wqs_unlock(wq_set);
}
wq_element = wq_next_element;
}
wait_queue_unlock(wq);
splx(s);
return(KERN_SUCCESS);
}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:43,代码来源:wait_queue.c
示例13: IOLog1
bool AppleRAIDMirrorSet::init()
{
IOLog1("AppleRAIDMirrorSet::init() called\n");
if (super::init() == false) return false;
arRebuildThreadCall = 0;
arSetCompleteThreadCall = 0;
arExpectingLiveAdd = 0;
arMaxReadRequestFactor = 32; // with the default 32KB blocksize -> 1 MB
queue_init(&arFailedRequestQueue);
setProperty(kAppleRAIDLevelNameKey, kAppleRAIDLevelNameMirror);
arAllocateRequestMethod = OSMemberFunctionCast(IOCommandGate::Action, this, &AppleRAIDSet::allocateRAIDRequest);
return true;
}
开发者ID:benoitse,项目名称:osx-10.9-opensource,代码行数:19,代码来源:AppleRAIDMirrorSet.cpp
示例14: REG_INSERT
/**
* @brief Initializes a thread structure.
* @note This is an internal functions, do not use it in application code.
*
* @param[in] tp pointer to the thread
* @param[in] prio the priority level for the new thread
* @return The same thread pointer passed as parameter.
*
* @notapi
*/
thread_t *_thread_init(thread_t *tp, tprio_t prio) {
tp->p_prio = prio;
tp->p_state = CH_STATE_WTSTART;
tp->p_flags = CH_FLAG_MODE_STATIC;
#if CH_CFG_TIME_QUANTUM > 0
tp->p_preempt = CH_CFG_TIME_QUANTUM;
#endif
#if CH_CFG_USE_MUTEXES
tp->p_realprio = prio;
tp->p_mtxlist = NULL;
#endif
#if CH_CFG_USE_EVENTS
tp->p_epending = 0;
#endif
#if CH_DBG_THREADS_PROFILING
tp->p_time = 0;
#endif
#if CH_CFG_USE_DYNAMIC
tp->p_refs = 1;
#endif
#if CH_CFG_USE_REGISTRY
tp->p_name = NULL;
REG_INSERT(tp);
#endif
#if CH_CFG_USE_WAITEXIT
list_init(&tp->p_waiting);
#endif
#if CH_CFG_USE_MESSAGES
queue_init(&tp->p_msgqueue);
#endif
#if CH_DBG_ENABLE_STACK_CHECK
tp->p_stklimit = (stkalign_t *)(tp + 1);
#endif
#if CH_DBG_STATISTICS || defined(__DOXYGEN__)
chTMObjectInit(&tp->p_stats);
chTMStartMeasurementX(&tp->p_stats);
#endif
#if defined(CH_CFG_THREAD_INIT_HOOK)
CH_CFG_THREAD_INIT_HOOK(tp);
#endif
return tp;
}
开发者ID:ChibiOS,项目名称:ChibiOS-gitmain,代码行数:53,代码来源:chthreads.c
示例15: logger_create
struct logger* logger_create(int type, char* dstip, int dstport, char* filepath)
{
struct logger* l = kzalloc(sizeof(struct logger), GFP_ATOMIC);
CHECK_IF(l == NULL, return NULL, "l is null");
queue_init(&l->mq, -1, _clean_log, QUEUE_FLAG_POP_BLOCK);
l->type = type;
l->lv = LOG_DEFAULT_LV;
if (type & LOG_UDP)
{
CHECK_IF(dstip == NULL, goto _ERROR, "LOG_UDP dstip is null");
CHECK_IF(dstport <= 0, goto _ERROR, "LOG_UDP dstport = %d invalid", dstport);
udp_init(&l->udp, NULL, UDP_PORT_ANY);
snprintf(l->remote.ipv4, INET_ADDRSTRLEN, "%s", dstip);
l->remote.port = dstport;
}
开发者ID:tacolin,项目名称:C_libtaco_k,代码行数:19,代码来源:klogger.c
示例16: main
int main(int argc,const char* const* argv){
int c;
const char* message = NULL;
while ( (c = getopt(argc,(char*const*)argv, "p:")) != -1) {
switch(c) {
/* -p $MSGID : preprocess message $MSGID */
caseof('p',message = optarg)
}
}
if(message) {
queue_init();
queue_process(message);
return 0;
}
clock_init(argv[0]);
clock_loop();
return 1;
}
开发者ID:byte-mug,项目名称:cumes,代码行数:19,代码来源:main.c
示例17: memcpy
void SparkProtocol::init(const char *id,
const SparkKeys &keys,
const SparkCallbacks &callbacks,
const SparkDescriptor &descriptor)
{
memcpy(server_public_key, keys.server_public, MAX_SERVER_PUBLIC_KEY_LENGTH);
memcpy(core_private_key, keys.core_private, MAX_DEVICE_PRIVATE_KEY_LENGTH);
memcpy(device_id, id, 12);
// when using this lib in C, constructor is never called
queue_init();
this->callbacks = callbacks;
this->descriptor = descriptor;
memset(event_handlers, 0, sizeof(event_handlers));
initialized = true;
}
开发者ID:adeeshag,项目名称:particle_project,代码行数:19,代码来源:spark_protocol.cpp
示例18: main
int main(void)
{
int size = 4;
int item_size = sizeof(int);
printk("Starting queue tests\n");
printk("- init queue with size of %d and item_size of %d\n", size, item_size);
queue_init(&queue, size, item_size);
printk("- adding thread A (%x)\n", &thread_a);
add_thread(&thread_a, HIGHEST_PRIORITY);
printk("- adding thread B(%x)\n", &thread_b);
add_thread(&thread_b, HIGHEST_PRIORITY - 1);
return 0;
}
开发者ID:raphui,项目名称:rnk,代码行数:19,代码来源:queue_test.c
示例19: pmu_init
/* main init */
void pmu_init(void)
{
mutex_init(&pmu_adc_mutex);
queue_init(&pmu_queue, false);
create_thread(pmu_thread,
pmu_thread_stack, sizeof(pmu_thread_stack), 0,
"PMU" IF_PRIO(, PRIORITY_SYSTEM) IF_COP(, CPU));
/* configure PMU interrutps */
for (int i = 0; i < 6; i++)
ints_msk[i] = 0xff;
#if CONFIG_CHARGING
ints_msk[0] &= ~PCF5063X_INT1_ADPINS & /* FireWire */
~PCF5063X_INT1_ADPREM;
#endif
ints_msk[1] &= ~PCF5063X_INT2_EXTON2R & /* USB */
~PCF5063X_INT2_EXTON2F;
#ifdef IPOD_ACCESSORY_PROTOCOL
ints_msk[1] &= ~PCF5063X_INT2_EXTON3R & /* Accessory */
~PCF5063X_INT2_EXTON3F;
#endif
ints_msk[5] &= ~PCF50635_INT6_GPIO2; /* Holdswitch */
pmu_write_multiple(PCF5063X_REG_INT1M, 5, ints_msk);
pmu_write(PCF50635_REG_INT6M, ints_msk[5]);
/* clear all */
unsigned char ints[5];
pmu_read_multiple(PCF5063X_REG_INT1, 5, ints);
pmu_read(PCF50635_REG_INT6);
/* get initial values */
#if CONFIG_CHARGING
pmu_read_inputs_mbcs();
#endif
pmu_read_inputs_ooc();
pmu_read_inputs_gpio();
eint_register(&pmu_eint);
}
开发者ID:Rockbox-Chinese-Community,项目名称:Rockbox-RCC,代码行数:43,代码来源:pmu-6g.c
示例20: filterOnTargets
/**
* Removes all rules which are not descendants of simulated DAG rooted at targets.
*
* @param rules Queue of rules which is read and modified.
* @param targets List of targets which act as roots.
* @return Void.
*/
static void filterOnTargets(queue_t **rules, char **targets){
queue_t *validRules = malloc(sizeof(queue_t));
queue_init(validRules);
int idx;
//initialize validRules with targets
for(idx=0; idx < queue_size(*rules);idx++){
rule_t *curRule = queue_at(*rules, idx);
int tarIdx;
for(tarIdx=0; targets[tarIdx] != NULL; tarIdx++){
if(strcmp(curRule->target, targets[tarIdx]) == 0){
queue_enqueue(validRules, curRule);
queue_remove_at(*rules, idx);
idx--;
break;
}
}
}
//repeated linear search for new valid targets
int prevSize = 0;
while(prevSize != queue_size(validRules)){
prevSize = queue_size(validRules);
for(idx=0; idx < queue_size(*rules); idx++){
rule_t *curRule = queue_at(*rules, idx);
if(findMatch(curRule, validRules)){
queue_enqueue(validRules, curRule);
queue_remove_at(*rules, idx);
idx--;
}
}
}
//cleanup old rules
queue_iterate(*rules, rule_free_adapter, 0);
queue_destroy(*rules);
free(*rules);
//assign new queue
*rules = validRules;
}
开发者ID:JLLLinn,项目名称:System-Programming,代码行数:49,代码来源:parser.c
注:本文中的queue_init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论