Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -635,10 +635,54 @@ - (void)performSelector: (SEL)selector withObject: (id)object1 withObject: (id)object2 afterDelay: (double)delay; +/** + * \brief Performs the specified selector on the specified thread. + * + * \param selector The selector to perform + * \param thread The thread on which to perform the selector + * \param waitUntilDone Whether to wait until the perform finished + */ +- (void)performSelector: (SEL)selector + onThread: (OFThread*)thread + waitUntilDone: (BOOL)waitUntilDone; + +/** + * \brief Performs the specified selector on the specified thread with the + * specified object. + * + * \param selector The selector to perform + * \param thread The thread on which to perform the selector + * \param object The object that is passed to the method specified by the + * selector + * \param waitUntilDone Whether to wait until the perform finished + */ +- (void)performSelector: (SEL)selector + onThread: (OFThread*)thread + withObject: (id)object + waitUntilDone: (BOOL)waitUntilDone; + +/** + * \brief Performs the specified selector on the specified thread with the + * specified objects. + * + * \param selector The selector to perform + * \param thread The thread on which to perform the selector + * \param object1 The first object that is passed to the method specified by the + * selector + * \param object2 The second object that is passed to the method specified by + * the selector + * \param waitUntilDone Whether to wait until the perform finished + */ +- (void)performSelector: (SEL)selector + onThread: (OFThread*)thread + withObject: (id)object1 + withObject: (id)object2 + waitUntilDone: (BOOL)waitUntilDone; + /** * \brief Performs the specified selector on the specified thread after the * specified delay. * * \param selector The selector to perform Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -620,10 +620,67 @@ target: self selector: selector object: object1 object: object2 repeats: NO]; + + objc_autoreleasePoolPop(pool); +} + +- (void)performSelector: (SEL)selector + onThread: (OFThread*)thread + waitUntilDone: (BOOL)waitUntilDone +{ + void *pool = objc_autoreleasePoolPush(); + OFTimer *timer = [OFTimer timerWithTimeInterval: 0 + target: self + selector: selector + repeats: NO]; + [[thread runLoop] addTimer: timer]; + + if (waitUntilDone) + [timer waitUntilDone]; + + objc_autoreleasePoolPop(pool); +} + +- (void)performSelector: (SEL)selector + onThread: (OFThread*)thread + withObject: (id)object + waitUntilDone: (BOOL)waitUntilDone +{ + void *pool = objc_autoreleasePoolPush(); + OFTimer *timer = [OFTimer timerWithTimeInterval: 0 + target: self + selector: selector + object: object + repeats: NO]; + [[thread runLoop] addTimer: timer]; + + if (waitUntilDone) + [timer waitUntilDone]; + + objc_autoreleasePoolPop(pool); +} + +- (void)performSelector: (SEL)selector + onThread: (OFThread*)thread + withObject: (id)object1 + withObject: (id)object2 + waitUntilDone: (BOOL)waitUntilDone +{ + void *pool = objc_autoreleasePoolPush(); + OFTimer *timer = [OFTimer timerWithTimeInterval: 0 + target: self + selector: selector + object: object1 + object: object2 + repeats: NO]; + [[thread runLoop] addTimer: timer]; + + if (waitUntilDone) + [timer waitUntilDone]; objc_autoreleasePoolPop(pool); } - (void)performSelector: (SEL)selector