示例#1
0
void test_queue_peek_tail(void)
{
	Queue *queue;

	/* Check peeking into an empty queue */

	queue = queue_new();

	assert(queue_peek_tail(queue) == NULL);

	queue_free(queue);

	/* Pop off all the values from the queue, making sure that peek
	 * has the correct value beforehand */

	queue = generate_queue();

	while (!queue_is_empty(queue)) {
		assert(queue_peek_tail(queue) == &variable1);
		assert(queue_pop_tail(queue) == &variable1);
		assert(queue_peek_tail(queue) == &variable2);
		assert(queue_pop_tail(queue) == &variable2);
		assert(queue_peek_tail(queue) == &variable3);
		assert(queue_pop_tail(queue) == &variable3);
		assert(queue_peek_tail(queue) == &variable4);
		assert(queue_pop_tail(queue) == &variable4);
	}

	assert(queue_peek_tail(queue) == NULL);

	queue_free(queue);
}
示例#2
0
void test_queue_pop_tail(void)
{
	Queue *queue;

	/* Check popping off an empty queue */

	queue = queue_new();

	assert(queue_pop_tail(queue) == NULL);

	queue_free(queue);

	/* Pop off all the values from the queue */

	queue = generate_queue();

	while (!queue_is_empty(queue)) {
		assert(queue_pop_tail(queue) == &variable1);
		assert(queue_pop_tail(queue) == &variable2);
		assert(queue_pop_tail(queue) == &variable3);
		assert(queue_pop_tail(queue) == &variable4);
	}

	assert(queue_pop_tail(queue) == NULL);

	queue_free(queue);
}
示例#3
0
void get_server_msqid(){
  //Get the servers msqid and set SERVER_MSQID
  int id, msqid;
  id = generate_msg_key(SERVER_PROJ_ID);
  
  msqid = generate_queue(id, 0600 | IPC_CREAT);
  SERVER_MSQID = msqid;
}
示例#4
0
void generate_my_msqid(){
  //Get this clients msqid and set CLIENT_MSQID
  int client_id, id, msq_id;

  client_id = get_client_id();
  set_anchor_for_new_client(client_id);

  id = generate_msg_key(client_id);
  msq_id = generate_queue(id, 0600 | IPC_CREAT);
  CLIENT_MSQID = msq_id;
  M_TYPE = 1;
}