/*  -
   Copyright (C) 2006 Weongyo Jeong (weongyo@gmail.com)

This file is part of ROVM.

ROVM is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.

ROVM is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING.  If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.  */

#include "types.h"
#include "mpool.h"
#include "tktree.h"
#include "clstree.h"
#include "sha1.h"
#include "listen.h"
#include "rovm.h"

#include "thread.h"

/* 이 파일은 thread 을 위한 wrapper 들로 구성되어 있습니다.  */

/**
   Thread 를 하나 생성한다.

   @param new	생성될 Thread 의 pointer.
   @param attr	생성될 Thread 의 Attribute.
   @param func	실행될 function.
   @param data	전달할 data.
   @param pool	Thread 에 필요한 메모리를 할당할 메모리 pool
 */
rc_status_t rc_thread_create (rc_thread_t **new,
			      rc_threadattr_t *attr,
			      rc_thread_start_t func,
			      void *data,
			      rc_pool_t *pool)
{
  return apr_thread_create (new, attr, func, data, pool);
}

/**
   자식 thread 가 join 될 때까지 기다린다.

   @param rv	thread 구조체의 exitval 가 반환된다.
   @param thd	Thread 의 pointer.
 */
rc_status_t rc_thread_join (rc_status_t *rv,
			    rc_thread_t *thd)
{
  return apr_thread_join (rv, thd);
}

/**
   Thread 의 attribute 를 생성한다.

   @param new	생성될 thread attribute
   @param pool	구조체 할당을 위한 메모리 pool
 */
rc_status_t rc_threadattr_create (rc_threadattr_t **new,
				  rc_pool_t *pool)
{
  return apr_threadattr_create (new, pool);
}

/**
   Thread attribute 를 설정한다.

   @param attr	Thread attribute
   @param on	Flags
 */
rc_status_t rc_threadattr_detach_set (rc_threadattr_t *attr,
				      rc_int32_t on)
{
  return apr_threadattr_detach_set (attr, on);
}

/**
   현재 thread 를 종료한다.

   @param thd	종료할 thread
   @param rv	이를 관리할 thread 에서 반환하는 반환값.
*/
rc_status_t rc_thread_exit (rc_thread_t *thd,
			    rc_status_t rv)
{
  return apr_thread_exit (thd, rv);
}

/**
   Thread 를 rc type 으로부터 os specific type 으로 변환한다.

   @param ot	변환할 rc thread
   @param rt	우리가 변환할 os specific thread
 */
rc_status_t rc_os_thread_get (rc_os_thread_t **ot,
			      rc_thread_t *rt)
{
  return apr_os_thread_get (ot, rt);
}
