コード例 #1
0
ファイル: typeinfo.cpp プロジェクト: bonewell/tun
int main() {
  B b;
  A& a = b;
  std::cout << "type=" << typeid(a).name() << std::endl;
  
  do_this(b);
  do_this(a);

  return 0;
}
コード例 #2
0
ファイル: sv_err.c プロジェクト: gbourgeo/42projects
void			sv_err(char *err, char *cmd, char *cmd2, t_fd *cl)
{
	static char	*replies[][50] = { ERROR1, ERROR2, ERROR3, ERROR4, ERROR5,
									ERROR6, ERROR7, ERROR8, ERROR9, ERROR10,
									ERROR11 };
	long		pos;

	pos = ft_atoi(err) - 400;
	if (pos >= 0 && pos <= ERR_LEN)
	{
		sv_cl_write(":", cl);
		sv_cl_write(e.name, cl);
		sv_cl_write(" ", cl);
		sv_cl_write(err, cl);
		sv_cl_write(" ", cl);
		sv_cl_write(cl->inf->nick, cl);
		if (replies[pos][0])
			do_this(replies[pos][0], replies[pos][1], cmd, cl);
		else if (cmd)
			do_that(replies[pos][1], cmd, cmd2, cl);
		if (replies[pos][2])
		{
			sv_cl_write(" ", cl);
			sv_cl_write(replies[pos][2], cl);
		}
		sv_cl_write(END_CHECK, cl);
	}
}
コード例 #3
0
ファイル: queue.c プロジェクト: caizongchao/open-mika
/*
 * Prototype:
 *   x_status x_queue_flush(x_Queue *queue, void(*do_this)(void *data))
 * Description:
 *   Flushes the queue, it releases all the messages. The queue will be empty.
 * Implementation:
 */
x_status x_queue_flush(x_queue queue, void(*do_this)(void *data)) {

	x_status status = xs_success;
	void * data;

	loempa(7,"o4w - queue - Begin flush");

	__try {

		EnterCriticalSection(&queue->w_critical_section);
		/*
		** We have the lock, either because nobody is reading from the queue, or another thread
		** has called this function and went into a pthread_cond_wait state, that temporarily
		** releases the above mutex. Anyhow, we can update the number of readers of the queue.
		*/
		if (queue->o4w_queue_deleted == 1) {
			status = xs_deleted;
			goto hastalavista;
		}

		if (queue->available == 0) {
			status = xs_success;
			goto hastalavista;
			loempa(5,"o4w - queue - hastalavista");
		}

		/*
		** OK, when we have reached this far, everything is OK to read messages ...
		*/

		while (queue->available) {
			data = (void *) *queue->read;
			queue->read += 1;
			if (queue->read == queue->limit) {
				queue->read = queue->messages;
			}
			queue->available -= 1;
			do_this(data);
		}

		/*
		** OK, a message was delivered successfuly, so we can signal waiting writers that there is
		** room again, let's signal this condition to a writing thread.
		*/
		
		PulseEvent(queue->w_hEvent);
hastalavista:
		loempa(5,"o4w - queue - hastalavista");
	}
	__finally {
		LeaveCriticalSection(&queue->w_critical_section);
	}

	loempa(7,"o4w - queue - end of flush");
	return status;
}