/**************************************************************************** * This file is part of the project AqHome. * AqHome (c) by 2025 Martin Preuss, all rights reserved. * * The license for this file can be found in the file COPYING which you * should have received along with this file. ****************************************************************************/ #ifdef HAVE_CONFIG_H # include #endif #include "./eventloop_p.h" #include AQH_EVENT_LOOP *AQH_EventLoop_new(void) { AQH_EVENT_LOOP *eventLoop; GWEN_NEW_OBJECT(AQH_EVENT_LOOP, eventLoop); eventLoop->fdObjectList=AQH_Object_List2_new(); eventLoop->timerObjectList=AQH_Object_List2_new(); return eventLoop; } void AQH_EventLoop_free(AQH_EVENT_LOOP *eventLoop) { if (eventLoop) { AQH_Object_List2_free(eventLoop->timerObjectList); AQH_Object_List2_free(eventLoop->fdObjectList); GWEN_FREE_OBJECT(eventLoop); } } void AQH_EventLoop_AddFdObject(AQH_EVENT_LOOP *eventLoop, AQH_OBJECT *o) { if (eventLoop && o && NULL==AQH_Object_List2_Contains(eventLoop->fdObjectList, o)) { AQH_Object_List2_PushBack(eventLoop->fdObjectList, o); } } void AQH_EventLoop_DelFdObject(AQH_EVENT_LOOP *eventLoop, AQH_OBJECT *o) { if (eventLoop && o) AQH_Object_List2_Remove(eventLoop->fdObjectList, o); } void AQH_EventLoop_AddTimerObject(AQH_EVENT_LOOP *eventLoop, AQH_OBJECT *o) { if (eventLoop && o && NULL==AQH_Object_List2_Contains(eventLoop->timerObjectList, o)) { AQH_Object_List2_PushBack(eventLoop->timerObjectList, o); } } void AQH_EventLoop_DelTimerObject(AQH_EVENT_LOOP *eventLoop, AQH_OBJECT *o) { if (eventLoop && o) AQH_Object_List2_Remove(eventLoop->timerObjectList, o); }