[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A question on discardEventsMatchingMask:beforeEvent:
From: |
David Chisnall |
Subject: |
Re: A question on discardEventsMatchingMask:beforeEvent: |
Date: |
Mon, 31 Jan 2011 09:59:10 +0000 |
On 31 Jan 2011, at 09:51, SPUeNTRUP - Kai Henningsen wrote:
>> When I was looking at it, I found it hard to see how best to make a fast
>> allocation/deallocation scheme thread-safe.
>
> I learned this from ptmalloc3
ptmalloc() is very heavily optimised for the case in which malloc() and free()
are both called in the same thread. For NSEvent, this may well not be the
case, as the event is delivered to a run loop, which may pass it off to another
thread.
Of course, if you want really fast NSEvent allocation and deallocation, then
you should take advantage of the fact that NSEvents are inserted at the bottom
of the run loop, are immutable, and rarely persist beyond a single run loop
iteration. You can then allocate an NSEvent subclass on the stack, inject
this, and have its -retain method return a copy of itself on the heap, so you
are only calling malloc() at all when someone tries to keep the event beyond
the run loop iteration.
This would require some tweaking of the current code, I think, because NSEvents
are queued by the run loop. Something for Banlu to play with...
David
-- Send from my Jacquard Loom
- Re: A question on discardEventsMatchingMask:beforeEvent:, (continued)
- Re: A question on discardEventsMatchingMask:beforeEvent:, Banlu Kemiyatorn, 2011/01/26
- Re: A question on discardEventsMatchingMask:beforeEvent:, Fred Kiefer, 2011/01/26
- Re: A question on discardEventsMatchingMask:beforeEvent:, Banlu Kemiyatorn, 2011/01/27
- Re: A question on discardEventsMatchingMask:beforeEvent:, Banlu Kemiyatorn, 2011/01/27
- Re: A question on discardEventsMatchingMask:beforeEvent:, Fred Kiefer, 2011/01/28
- Re: A question on discardEventsMatchingMask:beforeEvent:, Banlu Kemiyatorn, 2011/01/28
- Re: A question on discardEventsMatchingMask:beforeEvent:, Banlu Kemiyatorn, 2011/01/28
- Re: A question on discardEventsMatchingMask:beforeEvent:, Richard Frith-Macdonald, 2011/01/28
- Re: A question on discardEventsMatchingMask:beforeEvent:, Banlu Kemiyatorn, 2011/01/28
- Re: A question on discardEventsMatchingMask:beforeEvent:, SPUeNTRUP - Kai Henningsen, 2011/01/31
- Re: A question on discardEventsMatchingMask:beforeEvent:,
David Chisnall <=
- Re: A question on discardEventsMatchingMask:beforeEvent:, SPUeNTRUP - Kai Henningsen, 2011/01/31
- Re: A question on discardEventsMatchingMask:beforeEvent:, Fred Kiefer, 2011/01/29
- Re: A question on discardEventsMatchingMask:beforeEvent:, Dr. H. Nikolaus Schaller, 2011/01/29
- Re: A question on discardEventsMatchingMask:beforeEvent:, Banlu Kemiyatorn, 2011/01/29
- Re: A question on discardEventsMatchingMask:beforeEvent:, Banlu Kemiyatorn, 2011/01/29