2 Copyright © 2002-2006, The AROS Development Team. All rights reserved.
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>
13 #include "muimaster_intern.h"
16 extern struct Library
*MUIMasterBase
;
18 struct MUI_SemaphoreData
20 struct SignalSemaphore sem
;
23 /**************************************************************************
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
);
33 data
= INST_DATA(cl
, obj
);
35 InitSemaphore(&data
->sem
);
41 /**************************************************************************
42 MUIM_Semaphore_Attempt
43 **************************************************************************/
44 IPTR
Semaphore__MUIM_Attempt(struct IClass
*cl
, Object
*obj
, struct MUIP_Semaphore_Attempt
*msg
)
46 struct MUI_SemaphoreData
*data
= INST_DATA(cl
, obj
);
48 return (IPTR
)AttemptSemaphore(&data
->sem
);
51 /**************************************************************************
52 MUIM_Semaphore_AttemptShared
53 **************************************************************************/
54 IPTR
Semaphore__MUIM_AttemptShared(struct IClass
*cl
, Object
*obj
, struct MUIP_Semaphore_AttemptShared
*msg
)
56 struct MUI_SemaphoreData
*data
= INST_DATA(cl
, obj
);
58 return (IPTR
)AttemptSemaphoreShared(&data
->sem
);
61 /**************************************************************************
63 **************************************************************************/
64 IPTR
Semaphore__MUIM_Obtain(struct IClass
*cl
, Object
*obj
, struct MUIP_Semaphore_Obtain
*msg
)
66 struct MUI_SemaphoreData
*data
= INST_DATA(cl
, obj
);
68 ObtainSemaphore(&data
->sem
);
73 /**************************************************************************
74 MUIM_Semaphore_ObtainShared
75 **************************************************************************/
76 IPTR
Semaphore__MUIM_ObtainShared(struct IClass
*cl
, Object
*obj
, struct MUIP_Semaphore_ObtainShared
*msg
)
78 struct MUI_SemaphoreData
*data
= INST_DATA(cl
, obj
);
80 ObtainSemaphoreShared(&data
->sem
);
85 /**************************************************************************
86 MUIM_Semaphore_Release
87 **************************************************************************/
88 IPTR
Semaphore__MUIM_Release(struct IClass
*cl
, Object
*obj
, struct MUIP_Semaphore_Release
*msg
)
90 struct MUI_SemaphoreData
*data
= INST_DATA(cl
, obj
);
92 ReleaseSemaphore(&data
->sem
);
98 BOOPSI_DISPATCHER(IPTR
, Semaphore_Dispatcher
, cl
, obj
, msg
)
100 switch (msg
->MethodID
)
102 case OM_NEW
: return Semaphore__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
103 case MUIM_Semaphore_Attempt
: return Semaphore__MUIM_Attempt(cl
, obj
, (struct MUIP_Semaphore_Attempt
*)msg
);
104 case MUIM_Semaphore_AttemptShared
: return Semaphore__MUIM_AttemptShared(cl
, obj
, (struct MUIP_Semaphore_AttemptShared
*)msg
);
105 case MUIM_Semaphore_Obtain
: return Semaphore__MUIM_Obtain(cl
, obj
, (struct MUIP_Semaphore_Obtain
*)msg
);
106 case MUIM_Semaphore_ObtainShared
: return Semaphore__MUIM_ObtainShared(cl
, obj
, (struct MUIP_Semaphore_ObtainShared
*)msg
);
107 case MUIM_Semaphore_Release
: return Semaphore__MUIM_Release(cl
, obj
, (struct MUIP_Semaphore_Release
*)msg
);
110 return DoSuperMethodA(cl
, obj
, msg
);
112 BOOPSI_DISPATCHER_END
117 const struct __MUIBuiltinClass _MUI_Semaphore_desc
= {
120 sizeof(struct MUI_SemaphoreData
),
121 (void*)Semaphore_Dispatcher