Package org.rococoa.cocoa.foundation

Examples of org.rococoa.cocoa.foundation.NSAutoreleasePool.drain()


        // if you create a Foundation-only application or if you detach a thread—you need to create
        // your own autorelease pool.
        Thread thread = new Thread("test") {
            public void run() {
                NSAutoreleasePool second = NSAutoreleasePool.new_();
                second.drain();
            }
        };
        thread.start();
        thread.join();
        RococoaTestCase.assertRetainCount(2, idString);
View Full Code Here


       
        // it should now have been release'd
        assertRetainCount(expectedInitialRetainCount, alias);
       
        // now let the pool go
        pool.drain();

        assertRetainCount(expectedFinalRetainCount, alias);
    }

}
View Full Code Here

            pool = NSAutoreleasePool.new_();
            return callable.call();
        } catch (Exception e) {
            throw e instanceof RuntimeException ? ((RuntimeException)e) : new RuntimeException(e);
        } finally {
            if ( pool != null ) pool.drain();
        }
    }
}
View Full Code Here

    @Test
    public void garbageCollectDrainedPool() throws InterruptedException {
        Thread thread = new Thread("test") {
            public void run() {
                NSAutoreleasePool pool = NSAutoreleasePool.new_();
                pool.drain();
            }
        };
        thread.start();
        thread.join();
        RococoaTestCase.gc();
View Full Code Here


    @Test
    public void drainPoolAndFinalize() {
        NSAutoreleasePool pool = NSAutoreleasePool.new_();
        pool.drain();
        WeakReference<Object> reference = new WeakReference<Object>(pool);
        pool = null;
        while(reference.get() != null) {
            RococoaTestCase.gc();
        }
View Full Code Here

        assertRetainCount(1, idOfString); // autorelease does not increase the count
       
        Foundation.sendReturnsVoid(idOfString, "retain");
        assertRetainCount(2, idOfString);
       
        pool.drain();
        assertRetainCount(1, idOfString);

        Foundation.cfRelease(idOfString);
        // causes count to go to 0 and dispose will happen
    }
View Full Code Here

        ID idOfString = Foundation.sendReturnsID(idOfClass, "alloc");
        idOfString = Foundation.sendReturnsID(idOfString, "initWithCString:", "Hello world");
        assertRetainCount(1, idOfString);

        // show that it wasn't in the pool
        pool.drain();
        assertRetainCount(1, idOfString);
        Foundation.cfRelease(idOfString);
    }
   
}
View Full Code Here

        NSNumber value = reference.getValueAs(NSNumber.class);
        assertEquals(42, value.intValue());

        // we better have retained the result by the time it gets back
        assertEquals(3, value.retainCount());
        pool.drain();
        assertEquals(2, value.retainCount());
    }

    @Test
    public void testDelegate() {
View Full Code Here

            }
        });
        final ID delegate = callback.id();
        shunt.testCallbackWithReference(delegate);
        assertEquals("Callback to delegate failed", 0, count.getCount());
        pool.drain();
    }
}
View Full Code Here

        } catch (Throwable ex) {
            ex.printStackTrace(System.err);
            throw new RuntimeException("Unable to create screen capture for  " + _bundleIdentifier + " due to exception", ex);
        } finally {
            pool.drain();
        }

        return null;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.