* @brief This function will return the length of object list in object container. * * @param type is the type of object, which can be * RT_Object_Class_Thread/Semaphore/Mutex... etc * * @return the length of object list */
| 269 | * @return the length of object list |
| 270 | */ |
| 271 | int rt_object_get_length(enum rt_object_class_type type) |
| 272 | { |
| 273 | int count = 0; |
| 274 | rt_base_t level; |
| 275 | struct rt_list_node *node = RT_NULL; |
| 276 | struct rt_object_information *information = RT_NULL; |
| 277 | |
| 278 | information = rt_object_get_information((enum rt_object_class_type)type); |
| 279 | if (information == RT_NULL) return 0; |
| 280 | |
| 281 | level = rt_spin_lock_irqsave(&(information->spinlock)); |
| 282 | rt_list_for_each(node, &(information->object_list)) |
| 283 | { |
| 284 | count ++; |
| 285 | } |
| 286 | rt_spin_unlock_irqrestore(&(information->spinlock), level); |
| 287 | |
| 288 | return count; |
| 289 | } |
| 290 | RTM_EXPORT(rt_object_get_length); |
| 291 | |
| 292 | /** |