Indentation fix, cleanup.
[AROS.git] / rom / task / UnLockTaskList.c
blob7d495b78c4d74ac817df1b4139eb67c276a32b03
1 /*
2 Copyright © 2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 0
8 #include <aros/debug.h>
9 #include <exec/types.h>
10 #include <aros/libcall.h>
11 #include <proto/utility.h>
12 #include <resources/task.h>
14 #include <resources/task.h>
16 #include "taskres_intern.h"
18 /*****************************************************************************
20 NAME */
21 #include <proto/task.h>
23 AROS_LH1(void, UnLockTaskList,
25 /* SYNOPSIS */
26 AROS_LHA(ULONG, flags, D1),
28 /* LOCATION */
29 struct TaskResBase *, TaskResBase, 2, Task)
31 /* FUNCTION
32 Frees a lock on the task lists given by LockTaskList().
34 INPUTS
35 flags - the same value as given to LockTaskList().
37 RESULT
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
46 LockTaskList(), NextTaskEntry()
48 INTERNALS
50 *****************************************************************************/
52 AROS_LIBFUNC_INIT
54 struct TaskListPrivate *taskList, *tltmp;
55 struct Task *thisTask = FindTask(NULL);
57 D(bug("[TaskRes] UnLockTaskList: flags = $%lx\n", flags));
59 ReleaseSemaphore(&TaskResBase->trb_Sem);
61 ForeachNodeSafe(&TaskResBase->trb_LockedLists, taskList, tltmp)
63 if (((struct Task *)taskList->tlp_Node.ln_Name == thisTask) &&
64 (taskList->tlp_Flags == flags))
66 D(bug("[TaskRes] UnLockTaskList: Releasing TaskList @ 0x%p\n", taskList));
67 Remove(&taskList->tlp_Node);
68 FreeMem(taskList, sizeof(struct TaskListPrivate));
69 break;
73 /* If we are the last lock holder, do housecleaning */
74 if (IsListEmpty(&TaskResBase->trb_LockedLists))
76 struct TaskListEntry *taskEntry, *tetmp;
78 ForeachNodeSafe(&TaskResBase->trb_TaskList, taskEntry, tetmp)
80 if (taskEntry->tle_Task == NULL)
82 D(bug("[TaskRes] RemTask: destroying old taskentry @ 0x%p\n", taskEntry));
83 Remove(&taskEntry->tle_Node);
84 FreeMem(taskEntry, sizeof(struct TaskListEntry));
87 ForeachNodeSafe(&TaskResBase->trb_NewTasks, taskEntry, tetmp)
89 Remove(&taskEntry->tle_Node);
90 AddTail(&TaskResBase->trb_TaskList, &taskEntry->tle_Node);
93 AROS_LIBFUNC_EXIT
94 } /* UnLockTaskList */