Helixis 1.0
Task Programming API
sources/native/native_task_groups.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 2009-2011, helixis.org
00003 ** All rights reserved.
00004 **
00005 ** Redistribution and use in source and binary forms, with or without modification, are permitted provided
00006 ** that the following conditions are met:
00007 **
00008 ** Redistributions of source code must retain the above copyright notice, this list of conditions and the
00009 ** following disclaimer.
00010 **
00011 ** Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
00012 ** the following disclaimer in the documentation and/or other materials provided with the distribution.
00013 **
00014 ** Neither the name of the helixis.org nor the names of its contributors may be used to endorse or promote
00015 ** products derived from this software without specific prior written permission.
00016 **
00017 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
00018 ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00019 ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00020 ** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00021 ** TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00022 ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00023 ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00024 ** POSSIBILITY OF SUCH DAMAGE.
00025 */
00026 
00027 /*
00028 ** INCLUDES
00029 */
00030 
00031 #include "hlx/core.h"
00032 #include "helixis_internal.h"
00033 
00034 #if !defined(HLX_BUILD_WITH_PARALLEL_THREADING)
00035 
00036 #ifdef __cplusplus
00037 extern "C"      {
00038 #endif
00039 
00040 /*
00041 ** EXTERNALS
00042 */
00043 
00044 extern hlx_api gl_api;
00045 
00046 /*
00047 ** FUNCTIONS
00048 */
00049 
00050 void hlx_group_construct(hlx_group* group)
00051 {
00052         group->id = (hlx_group_id)group;
00053         hlx_list_construct(&group->tasks);
00054 }
00055 
00056 void hlx_group_destruct(hlx_group* group)
00057 {
00058         hlx_list_node* it;
00059         hlx_task* task;
00060 
00061     it = group->tasks.first;
00062         while (it != 0)
00063         {
00064                 task = it->data;
00065                 if (task->stack != 0)
00066                         gl_api.free_entry(task->stack);
00067                 gl_api.free_entry(it->data);
00068                 it = it->next;
00069         }
00070         hlx_list_clear(&group->tasks);
00071 }
00072 
00073 void hlx_group_add_task(hlx_group* group, hlx_task* task)
00074 {
00075         hlx_list_push_back(&group->tasks, task);
00076 }
00077 
00078 void hlx_group_del_task(hlx_group* group, hlx_task* task)
00079 {
00080         hlx_list_node* it;
00081 
00082         if ((it = hlx_list_find(&group->tasks, task)) == 0)
00083                 return;
00084         gl_api.free_entry(it->data);
00085         hlx_list_erase(&group->tasks, it);
00086 }
00087 
00088 atom_t hlx_group_get_size(hlx_group* group)
00089 {
00090  return (group->tasks.size);
00091 }
00092 
00093 #endif /* HLX_BUILD_WITH_PARALLEL_THREADING */
00094 
00095 #ifdef __cplusplus
00096 }
00097 #endif
00098 
00099 /*
00100 ** END OF FILE
00101 */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines