Tabs to spaces, more consistent formatting.
[AROS.git] / workbench / libs / muimaster / classes / semaphore.c
blob123ef46de9f76e0defc6263fd5ba12da2ba3ce13
1 /*
2 Copyright © 2002-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/semaphores.h>
7 #include <clib/alib_protos.h>
8 #include <proto/exec.h>
9 #include <proto/intuition.h>
10 #include <proto/muimaster.h>
12 #include "mui.h"
13 #include "muimaster_intern.h"
14 #include "support.h"
16 extern struct Library *MUIMasterBase;
18 struct MUI_SemaphoreData
20 struct SignalSemaphore sem;
23 /**************************************************************************
24 OM_NEW
25 **************************************************************************/
26 IPTR Semaphore__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg)
28 struct MUI_SemaphoreData *data;
30 obj = (Object *) DoSuperMethodA(cl, obj, (Msg) msg);
31 if (obj)
33 data = INST_DATA(cl, obj);
35 InitSemaphore(&data->sem);
38 return (IPTR) obj;
41 /**************************************************************************
42 MUIM_Semaphore_Attempt
43 **************************************************************************/
44 IPTR Semaphore__MUIM_Attempt(struct IClass *cl, Object *obj,
45 struct MUIP_Semaphore_Attempt *msg)
47 struct MUI_SemaphoreData *data = INST_DATA(cl, obj);
49 return (IPTR) AttemptSemaphore(&data->sem);
52 /**************************************************************************
53 MUIM_Semaphore_AttemptShared
54 **************************************************************************/
55 IPTR Semaphore__MUIM_AttemptShared(struct IClass *cl, Object *obj,
56 struct MUIP_Semaphore_AttemptShared *msg)
58 struct MUI_SemaphoreData *data = INST_DATA(cl, obj);
60 return (IPTR) AttemptSemaphoreShared(&data->sem);
63 /**************************************************************************
64 MUIM_Semaphore_Obtain
65 **************************************************************************/
66 IPTR Semaphore__MUIM_Obtain(struct IClass *cl, Object *obj,
67 struct MUIP_Semaphore_Obtain *msg)
69 struct MUI_SemaphoreData *data = INST_DATA(cl, obj);
71 ObtainSemaphore(&data->sem);
73 return 0;
76 /**************************************************************************
77 MUIM_Semaphore_ObtainShared
78 **************************************************************************/
79 IPTR Semaphore__MUIM_ObtainShared(struct IClass *cl, Object *obj,
80 struct MUIP_Semaphore_ObtainShared *msg)
82 struct MUI_SemaphoreData *data = INST_DATA(cl, obj);
84 ObtainSemaphoreShared(&data->sem);
86 return 0;
89 /**************************************************************************
90 MUIM_Semaphore_Release
91 **************************************************************************/
92 IPTR Semaphore__MUIM_Release(struct IClass *cl, Object *obj,
93 struct MUIP_Semaphore_Release *msg)
95 struct MUI_SemaphoreData *data = INST_DATA(cl, obj);
97 ReleaseSemaphore(&data->sem);
99 return 0;
103 BOOPSI_DISPATCHER(IPTR, Semaphore_Dispatcher, cl, obj, msg)
105 switch (msg->MethodID)
107 case OM_NEW:
108 return Semaphore__OM_NEW(cl, obj, (struct opSet *)msg);
109 case MUIM_Semaphore_Attempt:
110 return Semaphore__MUIM_Attempt(cl, obj,
111 (struct MUIP_Semaphore_Attempt *)msg);
112 case MUIM_Semaphore_AttemptShared:
113 return Semaphore__MUIM_AttemptShared(cl, obj,
114 (struct MUIP_Semaphore_AttemptShared *)msg);
115 case MUIM_Semaphore_Obtain:
116 return Semaphore__MUIM_Obtain(cl, obj,
117 (struct MUIP_Semaphore_Obtain *)msg);
118 case MUIM_Semaphore_ObtainShared:
119 return Semaphore__MUIM_ObtainShared(cl, obj,
120 (struct MUIP_Semaphore_ObtainShared *)msg);
121 case MUIM_Semaphore_Release:
122 return Semaphore__MUIM_Release(cl, obj,
123 (struct MUIP_Semaphore_Release *)msg);
126 return DoSuperMethodA(cl, obj, msg);
128 BOOPSI_DISPATCHER_END
131 * Class descriptor.
133 const struct __MUIBuiltinClass _MUI_Semaphore_desc =
135 MUIC_Semaphore,
136 ROOTCLASS,
137 sizeof(struct MUI_SemaphoreData),
138 (void *) Semaphore_Dispatcher