2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /*****************************************************************************
19 #include <aros/debug.h>
22 #include <proto/exec.h>
23 #include <libraries/commodities.h>
25 AROS_LH2(ULONG
, BrokerCommand
,
29 AROS_LHA(STRPTR
, name
, A0
),
30 AROS_LHA(ULONG
, command
, D0
),
34 struct Library
*, CxBase
, 33, Commodities
)
38 Notify a task connected to a certain broker of a state change.
42 name -- The name of the broker
43 command -- What to tell the task
47 0 if everything was OK, a negative value otherwise:
48 -1 -- Unknown broker 'name'
49 -2 -- No broker message port
50 -3 -- No memory for operation
54 This function is present in AmigaOS too but undocumented.
66 ******************************************************************************/
71 static char Exg
[] = "Exchange";
81 D(bug("Notifying %s\n", name
));
83 ObtainSemaphore(&GPB(CxBase
)->cx_SignalSemaphore
);
85 co
= (CxObj
*)FindName(&GPB(CxBase
)->cx_BrokerList
, name
);
86 error
= CheckStatus(co
, command
, CxBase
);
88 ReleaseSemaphore(&GPB(CxBase
)->cx_SignalSemaphore
);
90 D(bug("Notification done!\n"));
98 ULONG
CheckStatus(CxObj
*broker
, ULONG command
, struct Library
*CxBase
)
107 if (broker
->co_Ext
.co_BExt
->bext_MsgPort
== NULL
)
109 if (command
== CXCMD_KILL
&& broker
->co_Ext
.co_BExt
->bext_Task
!= NULL
)
111 /* Tell the task to shut itself down */
112 Signal(broker
->co_Ext
.co_BExt
->bext_Task
, SIGBREAKF_CTRL_E
);
120 msg
= (CxMsg
*)AllocCxStructure(CX_MESSAGE
, CXM_SINGLE
, CxBase
);
127 msg
->cxm_ID
= command
;
128 PutMsg(broker
->co_Ext
.co_BExt
->bext_MsgPort
, (struct Message
*)msg
);