예제 #1
0
파일: acl_mbox.c 프로젝트: QianErGe/acl
void acl_mbox_free(ACL_MBOX *mbox, void (*free_fn)(void*))
{
	acl_vstream_close(mbox->in);
	acl_vstream_close(mbox->out);
	acl_ypipe_free(mbox->ypipe, free_fn);
	acl_pthread_mutex_destroy(mbox->lock);
	acl_myfree(mbox);
}
예제 #2
0
파일: main.c 프로젝트: JingwenYoung/acl
int main(int argc, char *argv[])
{
	acl_pthread_attr_t attr;
	acl_pthread_t t1, t2;
	ACL_YPIPE *ypipe = acl_ypipe_new();
	int   ch;

	while ((ch = getopt(argc, argv, "hn:b:")) > 0) {
		switch (ch) {
		case 'h':
			usage(argv[0]);
			return 0;
		case 'n':
			__max = atoi(optarg);
			break;
		case 'b':
			__base = atoi(optarg);
			break;
		default:
			break;
		}
	}

	memset(__dummy, 'x', sizeof(__dummy));
	__dummy[sizeof(__dummy) - 1] = 0;

	acl_pthread_attr_init(&attr);
	acl_pthread_create(&t2, &attr, thread_consumer, ypipe);
	acl_pthread_create(&t1, &attr, thread_producer, ypipe);
	acl_pthread_join(t2, NULL);
	acl_pthread_join(t1, NULL);

	acl_ypipe_free(ypipe, NULL);
	printf("over\r\n");

	return 0;
}