Artifact e60316af1b43ab826d3c8ff8e96b7d7863fa834dbf5a1e18b822026807444ea8:
- File
src/OFKernelEventObserver_LockedQueue.h
— part of check-in
[e9b4700cb6]
at
2015-12-29 21:33:07
on branch trunk
— Refactor OFKernelEventObserver
This moves the locked queue for actions to
OFKernelEventObserver_LockedQueue, which is now used for select and
poll, but skipped for kqueue and epoll, as they natively support changes
from another thread.This fixes the problem that removing an object is delayed until the next
observe call - at which point it might have already been closed, meaning
the fd is no longer available. This was mainly a problem with kqueue, as
closing the fd already removed it from the kqueue, which then resulted
in an error being returned when trying to manually remove the fd from
the kqueue. (user: js, size: 1283) [annotate] [blame] [check-ins using] [more...]
/* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFKernelEventObserver.h" OF_ASSUME_NONNULL_BEGIN @class OFMutableArray OF_GENERIC(ObjectType); @class OFDataArray; #ifdef OF_HAVE_THREADS @class OFMutex; #endif @interface OFKernelEventObserver_LockedQueue: OFKernelEventObserver { OFDataArray *_queueActions, *_queueFDs; OFMutableArray *_queueObjects; #ifdef OF_HAVE_THREADS OFMutex *_mutex; #endif } - (void)OF_addObjectForReading: (id)object fileDescriptor: (int)fd; - (void)OF_addObjectForWriting: (id)object fileDescriptor: (int)fd; - (void)OF_removeObjectForReading: (id)object fileDescriptor: (int)fd; - (void)OF_removeObjectForWriting: (id)object fileDescriptor: (int)fd; - (void)OF_processQueue; @end OF_ASSUME_NONNULL_END