Hi,
Ich schreibe also:
Code
LOCK_TIMERS_READ;
LOCK_SCHEDULES_READ;
const cTimer *timer = ...
const cEvent *event = timer->Event();
Ich darf event also verwenden, da ich einen Lock auf schedules habe.
Aber Moment, event könnte ja gelöscht worden sein: Aus tools.h:
Code: tools.h
///< You may keep pointers to objects in this list, even after releasing
///< the lock. However, you may only access such objects if you are
///< holding a proper lock again. If an object has been deleted from the list
///< while you did not hold a lock (for instance by an other thread), the
///< object will still be there, but no longer within this list (it is then
///< stored in the ListGarbageCollector). That way even if you access the object
///< after it has been deleted, you won't cause a segfault. You can call the
///< Contains() function to check whether an object you are holding a pointer
///< to is still in the list. Note that the garbage collector is purged when
///< the usual housekeeping is done.
Ich weiß ja jetzt nicht, ob der garbage collector das event schon gelöscht hat.
Ich könnte das nun mit Contains() überprüfen, dazu müsste ich aber Contains() auf cSchedule::events; anwenden. Was ich aus 2 Gründen nicht kann:
- cSchedule::events ist private
- Ich kenne den cSchedule, in dem dieses Event ist, nicht (wäre ev. mit einem Loop über alle schedules lösbar)
Wie muss ich also vorgehen, um zu prüfen ob der garbage collector das event schon gelöscht hat?
~ Markus