00001 /* 00002 * Copyright 2008-2010 Arsen Chaloyan 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 * $Id: apt_task_msg.h 1474 2010-02-07 20:51:47Z achaloyan $ 00017 */ 00018 00019 #ifndef APT_TASK_MSG_H 00020 #define APT_TASK_MSG_H 00021 00022 /** 00023 * @file apt_task_msg.h 00024 * @brief Task Message Base Definition 00025 */ 00026 00027 #include "apt.h" 00028 00029 APT_BEGIN_EXTERN_C 00030 00031 /** Enumeration of task message types */ 00032 typedef enum { 00033 TASK_MSG_CORE, /**< core task message type */ 00034 TASK_MSG_USER /**< user defined task messages start from here */ 00035 } apt_task_msg_type_e; 00036 00037 /** Enumeration of core task messages */ 00038 typedef enum { 00039 CORE_TASK_MSG_NONE, /**< indefinite message */ 00040 CORE_TASK_MSG_START_COMPLETE, /**< start-complete message */ 00041 CORE_TASK_MSG_TERMINATE_REQUEST, /**< terminate-request message */ 00042 CORE_TASK_MSG_TERMINATE_COMPLETE /**< terminate-complete message */ 00043 } apt_core_task_msg_type_e; 00044 00045 /** Opaque task message declaration */ 00046 typedef struct apt_task_msg_t apt_task_msg_t; 00047 /** Opaque task message pool declaration */ 00048 typedef struct apt_task_msg_pool_t apt_task_msg_pool_t; 00049 00050 /** Task message is used for inter task communication */ 00051 struct apt_task_msg_t { 00052 /** Message pool the task message is allocated from */ 00053 apt_task_msg_pool_t *msg_pool; 00054 /** Task msg type */ 00055 apt_task_msg_type_e type; 00056 /** Task msg sub type */ 00057 int sub_type; 00058 /** Context specific data */ 00059 char data[1]; 00060 }; 00061 00062 00063 /** Create pool of task messages with dynamic allocation of messages (no actual pool is created) */ 00064 APT_DECLARE(apt_task_msg_pool_t*) apt_task_msg_pool_create_dynamic(apr_size_t msg_size, apr_pool_t *pool); 00065 00066 /** Create pool of task messages with static allocation of messages */ 00067 APT_DECLARE(apt_task_msg_pool_t*) apt_task_msg_pool_create_static(apr_size_t msg_size, apr_size_t msg_pool_size, apr_pool_t *pool); 00068 00069 /** Destroy pool of task messages */ 00070 APT_DECLARE(void) apt_task_msg_pool_destroy(apt_task_msg_pool_t *msg_pool); 00071 00072 00073 /** Acquire task message from task message pool */ 00074 APT_DECLARE(apt_task_msg_t*) apt_task_msg_acquire(apt_task_msg_pool_t *task_msg_pool); 00075 00076 /** Realese task message */ 00077 APT_DECLARE(void) apt_task_msg_release(apt_task_msg_t *task_msg); 00078 00079 00080 APT_END_EXTERN_C 00081 00082 #endif /* APT_TASK_MSG_H */