2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: RemNamedObject() - Remove a NamedObject from a NameSpace.
8 #include <proto/exec.h>
11 /*****************************************************************************
14 #include <utility/name.h>
15 #include <proto/utility.h>
17 AROS_LH2(void, RemNamedObject
,
20 AROS_LHA(struct NamedObject
*, object
, A0
),
21 AROS_LHA(struct Message
*, message
, A1
),
24 struct UtilityBase
*, UtilityBase
, 44, Utility
)
27 Remove a NamedObject from a namespace.
29 If the NamedObject cannot be removed at the time of this call, then
30 the call will return without removing the NamedObject. It will
31 mark the NamedObject as "waiting for removal".
33 When the NamedObject is ready to be freed, the supplied message
34 will be ReplyMsg()'d with the message->mn_Node.ln_Name field
36 - the address of the NamedObject that was removed. In this case
37 you can free the NamedObject yourself.
38 - NULL. In this case, another Task has freed the NamedObject,
39 and you should not do so.
42 object - The NamedObject to attempt to remove.
43 message - The message to send. This message is a standard
44 Exec Message, which MUST have the mn_ReplyPort
45 field correctly set. The mn_Node.ln_Name field
46 will contain the address of the NamedObject or NULL
47 upon arrival at your port.
50 The NamedObject will be removed if possible, or marked for removal
51 at the next best moment.
54 Since this function effectively does a ReleaseNamedObject(), you
55 must have found this object first.
62 AttemptRemNamedObject(), AddNamedObject()
65 AttemptRemNamedObject() calls this function with a NULL message,
66 expecting that we remove the object if possible, or just return.
68 ReleaseNamedObject() also calls this with a NULL message.
71 29-10-95 digulla automatically created from
72 utility_lib.fd and clib/utility_protos.h
73 11-08-96 iaint Adapted for AROS for stuff I did earlier.
74 09-02-1997 iaint Improved Message handling.
76 *****************************************************************************/
81 struct IntNamedObject
*no
;
85 no
= GetIntNamedObject( object
);
86 ns
= no
->no_ParentSpace
;
88 /* If ns == 0, then this node hasn't been added to anywhere */
91 /* Whether we free now, or later, the message handling is
92 the same. So we use the same code.
94 The Forbid() is to prevent two tasks from trying to
95 attach a message at the same time.
101 if( no
->no_FreeMessage
== NULL
)
103 /* This is the message, mark for later */
104 message
->mn_Node
.ln_Name
= (STRPTR
)object
;
105 no
->no_FreeMessage
= message
;
109 /* This message is not it, return NULL name. */
110 message
->mn_Node
.ln_Name
= NULL
;
117 if(no
->no_UseCount
== 0)
119 /* Ok, so we can remove the NamedObject */
120 ObtainSemaphore( &ns
->ns_Lock
);
122 Remove( (struct Node
*)&no
->no_Node
);
124 if(no
->no_FreeMessage
)
126 ReplyMsg( no
->no_FreeMessage
);
128 ReleaseSemaphore( &ns
->ns_Lock
);
137 } /* RemNamedObject */