本文整理汇总了C++中queue_create函数的典型用法代码示例。如果您正苦于以下问题:C++ queue_create函数的具体用法?C++ queue_create怎么用?C++ queue_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了queue_create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char *argv[])
{
struct queue *queue;
plan (NO_PLAN);
if (!(queue = queue_create (true)))
BAIL_OUT ("queue_create() failed");
single_job_check (queue);
multi_job_check (queue);
queue_destroy (queue);
done_testing ();
}
开发者ID:flux-framework,项目名称:flux-core,代码行数:15,代码来源:submit.c
示例2: queue_push
int queue_push(pqueuenode header,pqueueelem elem){
pqueuenode node = queue_create();
if(header->_tailer == NULL){
header->_tailer = node;
header->_fronter = node;
node->elem = *elem;
}
else {
header->_tailer->_next = node;
header->_tailer = node;
node->elem = *elem;
}
header->size++;
return 0;
}
开发者ID:j1111011,项目名称:bdsl,代码行数:15,代码来源:queue.c
示例3: multi_thread_test
static void multi_thread_test(void)
{
pthread_t consumer_t;
pthread_t producer_t;
Queue* queue = queue_create(NULL, NULL);
pthread_create(&producer_t, NULL, producer_run, (void*)queue);
pthread_create(&consumer_t, NULL, consumer_run, (void*)queue);
pthread_join(consumer_t, NULL);
pthread_join(producer_t, NULL);
consumer_run((void*)queue);
}
开发者ID:suzp1984,项目名称:donkey,代码行数:15,代码来源:queue.c
示例4: chan_new
static int chan_new(lua_State* L)
{
const char* name = _lua_arg_string(L, 1, NULL, _usage_new);
int limit = _lua_arg_integer(L, 2, 1, 0, _usage_new);
struct queue_t* q = queue_create(name, limit);
if (!queues_add(q))
{
queue_destroy(q);
lua_pushnil(L);
lua_pushstring(L, "chan name duplicated");
return 2;
}
chan_pushqueue(L, q);
return 1;
}
开发者ID:lqefn,项目名称:lua-chan,代码行数:15,代码来源:lua-chan.c
示例5: task_create
/*!
* Creates a task which encapsulates a service.
* The reason for this is to make it possible to observe services and to track
* dependencies. A task can be both an observer and a subject since it uses
* C inheritance from the \c struct \c subject_t.
*
* \param service - A service that is going to be encapsulated into a task.
*
* \return A task which encapsulates a service.
*/
task_t * task_create(struct service_t *service, struct task_handler_t *handler)
{
if (service->name != NULL) {
task_t * this_ptr = (task_t*) malloc(sizeof(task_t));
if (this_ptr != NULL) {
this_ptr->task_id = hash_generate(service->name);
this_ptr->dependency_queue = NULL;
this_ptr->service = service;
this_ptr->task_handler = handler;
this_ptr->counter = 0;
subject_init((subject_t*) this_ptr);
observer_set_notify((observer_t*) this_ptr, task_notify);
/* Check if there is a provides string, if there isn't any provides
* string, use the task name instead for the generated id. */
if (service->provides != NULL) {
this_ptr->provides_id = hash_generate(service->provides);
} else {
this_ptr->provides_id = this_ptr->task_id;
}
if (service->dependency != NULL) {
char **dependency_arg = (char**) service->dependency;
task_dependency_t *dependency;
this_ptr->dependency_queue = queue_create();
while (*dependency_arg != NULL) {
printf("%s dep: %s\n",service->name, *dependency_arg);
dependency = (task_dependency_t*) malloc(sizeof(
task_dependency_t));
dependency->name = *dependency_arg;
dependency->id = hash_generate(dependency->name);
dependency->task = NULL;
queue_push(this_ptr->dependency_queue, dependency);
dependency_arg++;
}
}
}
return this_ptr;
}
return NULL;
}
开发者ID:PeterJohansson,项目名称:speedy,代码行数:58,代码来源:task.c
示例6: main
int main(int argc, char const *argv[])
{
void * queue;
queue = queue_create();
teacher_t t[50];
for (int i = 0 ; i < 50; i++)
{
t[i].age = i;
queue_insert(queue, &t[i]);
}
teacher_t * p;
int k = queue_length(queue);
for (int i = 0; i < k-1; i++)
{
p = (teacher_t *)queue_delete(queue);
fprintf(stdout, "%d ", p->age);
}
fprintf(stdout, "\n");
p = (teacher_t *)queue_head(queue);
fprintf(stdout, "%d ", p->age);
fprintf(stdout, "\n");
queue_delete(queue);
for (int i = 0 ; i < 50; i++)
{
t[i].age = i + 100;
queue_insert(queue, &t[i]);
}
if (!queue_empty(queue))
fprintf(stdout, "queue is not empty\n");
k = queue_length(queue);
for (int i = 0; i < k; i++)
{
p = (teacher_t *)queue_delete(queue);
fprintf(stdout, "%d ", p->age);
}
fprintf(stdout, "\n");
if (queue_empty(queue))
fprintf(stdout, "queue not empty\n");
queue_destroy(queue);
return 0;
}
开发者ID:fonglee,项目名称:just_for_fun,代码行数:48,代码来源:test.c
示例7: main
int main(){
queue *Q;
Q = queue_create();
int i ;
for(i = 0;i < 5;i++){
queue_in(Q,i);
}
for(i = 0;i < 5;i++){
int test;
test = queue_out(Q);
printf("%d ",test);
printf("\n");
}
}
开发者ID:zmr961006,项目名称:DSAA,代码行数:16,代码来源:queue_array.c
示例8: queue_test_enqueue
static void
queue_test_enqueue(element_t e,
int (*cmp)(element_t, element_t, int), int elem_sz)
{
queue_t q = queue_create(0);
element_t elem;
queue_enqueue(q, e);
elem = queue_dequeue(q);
assert(cmp(e, elem, elem_sz));
queue_delete(&q);
fprintf(stdout, "Testing queue enqueue and dequeue success ...\n");
}
开发者ID:hbfhaapy,项目名称:study,代码行数:16,代码来源:main.c
示例9: inotifyStart
int inotifyStart()
{
if (inotify_fd > 0)
{
queue_t q;
q = queue_create (128);
process_inotify_events (q, inotify_fd);
//}
printf ("\nTerminating\n");
//close_inotify_fd (inotify_fd);
queue_destroy (q);
}
return 0;
}
开发者ID:Nymphetaminer,项目名称:dsl-n55u,代码行数:16,代码来源:inotify.c
示例10: debug
struct pool *allocate_pool(size_t size)
{
debug("ALLOCATE-POOL", "allocating pool for size %d, pre-allocating %d slots (%d bytes)",
size, prealloclen, prealloclen * (size + headerlen));
struct pool *p = (struct pool *) malloc(sizeof(struct pool));
p->freed = queue_create();
p->size = size;
p->slots = prealloclen;
p->cursor = 0;
// pre-allocate some slots
p->data = malloc((size + headerlen) * prealloclen);
return p;
}
开发者ID:robbassi,项目名称:memory-pool,代码行数:16,代码来源:pool.c
示例11: main
int main() {
queue *q = queue_create(8, NULL);
assert(q != NULL);
int a = 10;
int b = 20;
enqueue(q, &a);
enqueue(q, &b);
printf("size=%d\n", queue_size(q));
assert(queue_full(q) != true);
printf("%d\n", *(int *)dequeue(q));
printf("%d\n", *(int *)dequeue(q));
assert(queue_empty(q) != false);
queue_release(q);
}
开发者ID:jash16,项目名称:algo,代码行数:16,代码来源:queue.c
示例12: printf
thread_pool_t *thread_pool_create(int size, thread_func_t func, void *data)
{
int i = 0;
thread_pool_t *thread_pool = NULL;
if(size <= 0){
return NULL;
}
thread_pool = (thread_pool_t *)MALLOC_WRAPPER(sizeof(thread_pool_t));
if(NULL == thread_pool){
printf("MALLOC_WRAPPER for thread pool failed.\n");
return NULL;
}
thread_pool->threads = (thread_context_t *)MALLOC_WRAPPER(sizeof(thread_context_t) * size);
if(NULL == thread_pool->threads){
printf("MALLOC_WRAPPER for thread_pool->threads failed.\n");
thread_pool_destroy(&thread_pool);
return NULL;
}
bzero(thread_pool->threads, sizeof(thread_context_t) * size);
thread_pool->thread_num = size;
thread_pool->queue = queue_create(1024);
if(NULL == thread_pool->queue){
printf("queue_create for thread_pool->queue failed.\n");
thread_pool_destroy(&thread_pool);
return NULL;
}
thread_pool->data = data;
for(i = 0; i < size; i++){
thread_pool->threads[i].id = i;
thread_pool->threads[i].thread_pool = thread_pool;
thread_pool->threads[i].work_continue = 1;
if(0 != pthread_create(&thread_pool->threads[i].thread,
NULL, func, &thread_pool->threads[i])){
printf("create thread[%d] for thread pool failed.\n", i);
thread_pool_destroy(&thread_pool);
return NULL;
}
}
return thread_pool;
}
开发者ID:eyehere,项目名称:libeasy,代码行数:47,代码来源:ethread_pool.c
示例13: append_apply_test
int append_apply_test(){
queue* q = queue_create();
int x = 0;
int y = 1;
int z = 2;
queue_append(q, &x);
queue_append(q, &y);
queue_append(q, &z);
queue_append(q, &x);
printf("Queue size is %zu\n", queue_size(q));
int index = 0;
queue_apply(q, show_one, &index);
queue_destroy(q,false);
return 0;
}
开发者ID:kcorman,项目名称:cse451,代码行数:17,代码来源:queuetest.c
示例14: create_semaphore
int create_semaphore(int value)
{
int sem_index = get_available_semaphore_slot();
if (sem_index == -1) {
printf("Error: maximum number of semaphores already in use.\n");
return -1;
}
/* Create a new semaphore. */
num_sem++;
sem_t *sem = malloc(sizeof(sem_t));
sem->init = value;
sem->count = value;
sem->wait_queue = queue_create();
/* Insert the semaphore in the first empty slot in the table. */
sem_table[sem_index] = sem;
return sem_index;
}
开发者ID:andrewsmartin,项目名称:simple-thread-api,代码行数:17,代码来源:thread.c
示例15: my_init_lib
int my_init_lib()
{
char CLIENT_SOCK[] = "/tmp/clientXXXXXX";
if(mkstemp(CLIENT_SOCK) < 0) {
printf("[my_init_lib] Unable to create client socket.\n");
return -1;
}
if(snfs_init(CLIENT_SOCK, SERVER_SOCK) < 0) {
printf("[my_init_lib] Unable to initialize SNFS API.\n");
return -1;
}
Open_files_list = queue_create();
Lib_initted = 1;
return 0;
}
开发者ID:shadowpt,项目名称:sampleProject2,代码行数:17,代码来源:myfs.c
示例16: remove_value_test
int remove_value_test(){
queue *q = queue_create();
int x = 0, y = 1, z = 2;
queue_append(q, &x);
queue_append(q, &y);
queue_append(q, &z);
assert(queue_size(q) == 3);
int *ret_val;
queue_remove(q, (queue_element **)&ret_val);
assert(*ret_val == x);
queue_remove(q, (queue_element **)&ret_val);
assert(*ret_val == y);
queue_remove(q, (queue_element **)&ret_val);
assert(*ret_val == z);
queue_destroy(q,false);
return 0;
}
开发者ID:kcorman,项目名称:cse451,代码行数:17,代码来源:queuetest.c
示例17: int
thread_pool_t *thread_pool_create(unsigned int threads,
int (*task_exec)(void *task))
{
thread_pool_t *this_ptr = (thread_pool_t*) malloc(sizeof(thread_pool_t));
int i;
if ((this_ptr != NULL) && (task_exec != NULL)) {
this_ptr->task_exec = task_exec;
this_ptr->threads = (pthread_t*) malloc(sizeof(pthread_t) * threads - 1);
this_ptr->condititon = (pthread_cond_t*) malloc(sizeof(pthread_cond_t));
this_ptr->mutex = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t));
this_ptr->queue = queue_create();
if ((this_ptr->queue != NULL) && (this_ptr->threads != NULL) &&
(this_ptr->condititon != NULL) && (this_ptr->mutex != NULL)) {
this_ptr->continue_thread_pool = true;
if (threads > 0) {
this_ptr->thread_size = threads - 1;
} else {
this_ptr->thread_size = 0;
}
this_ptr->passive_threads = 0;
this_ptr->tasks = 0;
pthread_cond_init(this_ptr->condititon, NULL);
pthread_mutex_init(this_ptr->mutex, NULL);
for (i = 0; i < this_ptr->thread_size; i++) {
pthread_create(&this_ptr->threads[i], NULL,
thread_pool_run_thread, this_ptr);
}
} else {
free(this_ptr->threads);
free(this_ptr->condititon);
free(this_ptr->mutex);
queue_destroy(this_ptr->queue);
free(this_ptr);
this_ptr = NULL;
}
}
return this_ptr;
}
开发者ID:PeterJohansson,项目名称:speedy,代码行数:45,代码来源:thread_pool.c
示例18: libtcas_double_cache_init
TCAS_Error_Code libtcas_double_cache_init(const char *filename, tcas_u32 fpsNumerator, tcas_u32 fpsDenominator, tcas_u16 width, tcas_u16 height, int maxFrameCount, int maxFrameChunkCount, int fileCacheSize, TCAS_pDoubleCache pDoubleCache) {
TCAS_Error_Code error;
error = libtcas_frame_chunks_cache_init(filename, fpsNumerator, fpsDenominator, width, height, maxFrameChunkCount, fileCacheSize, &pDoubleCache->dcpArgs.fcc);
if (tcas_error_success != error)
return error;
pDoubleCache->dcpArgs.width = width;
pDoubleCache->dcpArgs.height = height;
pDoubleCache->minFrame = (tcas_u32)((tcas_u64)pDoubleCache->dcpArgs.fcc.fccpArgs.header.minTime * fpsNumerator / (fpsDenominator * 1000)) + 1;
pDoubleCache->maxFrame = (tcas_u32)((tcas_u64)pDoubleCache->dcpArgs.fcc.fccpArgs.header.maxTime * fpsNumerator / (fpsDenominator * 1000)) + 1;
pDoubleCache->maxFrameCount = maxFrameCount;
queue_create(&pDoubleCache->qFrames, sizeof(TCAS_QueuedFrame), pDoubleCache->maxFrameCount, NULL, NULL); /* stores pointers to frame buffers */
pDoubleCache->semQueue = CreateSemaphore(NULL, 0, pDoubleCache->maxFrameCount, NULL);
pDoubleCache->semFrames = CreateSemaphore(NULL, 0, pDoubleCache->maxFrameCount, NULL);
InitializeCriticalSection(&pDoubleCache->lock);
pDoubleCache->active = 1;
pDoubleCache->tdWorker = CreateThread(NULL, 0, _libtcas_create_frame_with_chunks_cached_worker_proc, pDoubleCache, 0, &pDoubleCache->threadID);
return tcas_error_success;
}
开发者ID:Lichtavat,项目名称:TCAX,代码行数:18,代码来源:hla_double_cache.c
示例19: queue_create
/* Create queue of size jobs
* id: [0:size-1]
*/
struct queue *make_test_queue (int size)
{
struct queue *q;
flux_jobid_t id;
q = queue_create ();
if (!q)
BAIL_OUT ("could not create queue");
for (id = 0; id < size; id++) {
struct job *j;
if (!(j = job_create (id, 0, 0, 0, 0)))
BAIL_OUT ("job_create failed");
if (queue_insert (q, j) < 0)
BAIL_OUT ("queue_insert failed");
}
return q;
}
开发者ID:grondo,项目名称:flux-core,代码行数:21,代码来源:list.c
示例20: main
int main(void)
{
t_logger *logger;
t_queue *queue;
int a;
int *b;
a = 5;
queue = queue_create();
if (queue_enqueue(queue, &a) < 0)
return (-1);
b = (int *)queue_dequeue(queue);
queue_destroy(queue);
logger = logger_create();
logger_write("Ceci est une gestion d\'erreur.\n");
logger_destroy();
return (0);
}
开发者ID:BelaBelphegor,项目名称:Crawler-JS,代码行数:18,代码来源:main.c
注:本文中的queue_create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论