mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-26 10:11:03 +00:00
Improve cache ahndling.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19293 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bd51b8caea
commit
20c509536e
2 changed files with 40 additions and 14 deletions
|
@ -1,3 +1,10 @@
|
|||
2004-05-12 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSURL.m: ([-loadResourceDataNotifyingClient:usingCache:])
|
||||
used cached information if requested. Always load using a cached
|
||||
handle so that results will be available to later calls.
|
||||
Addresses bug #8901
|
||||
|
||||
2004-05-09 David Ayers <d.ayers@inode.at>
|
||||
|
||||
* Headers/Additions/GNUstepBase/GSObjCRuntime.h
|
||||
|
|
|
@ -1132,25 +1132,44 @@ static unsigned urlAlign;
|
|||
- (void) loadResourceDataNotifyingClient: (id)client
|
||||
usingCache: (BOOL)shouldUseCache
|
||||
{
|
||||
NSURLHandle *handle = [self URLHandleUsingCache: shouldUseCache];
|
||||
NSURLHandle *handle = [self URLHandleUsingCache: YES];
|
||||
NSData *d;
|
||||
|
||||
if (client != nil)
|
||||
if (shouldUseCache == YES && (d = [handle availableResourceData]) != nil)
|
||||
{
|
||||
[clientsLock lock];
|
||||
if (_clients == 0)
|
||||
/*
|
||||
* We already have cached data we should use.
|
||||
*/
|
||||
if ([client respondsToSelector:
|
||||
@selector(URL:resourceDataDidBecomeAvailable:)])
|
||||
{
|
||||
_clients = NSCreateMapTable (NSObjectMapKeyCallBacks,
|
||||
NSNonRetainedObjectMapValueCallBacks, 0);
|
||||
[client URL: self resourceDataDidBecomeAvailable: d];
|
||||
}
|
||||
if ([client respondsToSelector: @selector(URLResourceDidFinishLoading:)])
|
||||
{
|
||||
[client URLResourceDidFinishLoading: self];
|
||||
}
|
||||
NSMapInsert((NSMapTable*)_clients, (void*)handle, (void*)client);
|
||||
[clientsLock unlock];
|
||||
[handle addClient: self];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (client != nil)
|
||||
{
|
||||
[clientsLock lock];
|
||||
if (_clients == 0)
|
||||
{
|
||||
_clients = NSCreateMapTable (NSObjectMapKeyCallBacks,
|
||||
NSNonRetainedObjectMapValueCallBacks, 0);
|
||||
}
|
||||
NSMapInsert((NSMapTable*)_clients, (void*)handle, (void*)client);
|
||||
[clientsLock unlock];
|
||||
[handle addClient: self];
|
||||
}
|
||||
|
||||
/*
|
||||
* Kick off the load process.
|
||||
*/
|
||||
[handle loadInBackground];
|
||||
/*
|
||||
* Kick off the load process.
|
||||
*/
|
||||
[handle loadInBackground];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1335,7 +1354,7 @@ static unsigned urlAlign;
|
|||
|
||||
/**
|
||||
* Loads the resource data for the represented URL and returns the result.
|
||||
* The shoulduseCache flag determines whether an existing cached NSURLHandle
|
||||
* The shouldUseCache flag determines whether an existing cached NSURLHandle
|
||||
* can be used to provide the data.
|
||||
*/
|
||||
- (NSData*) resourceDataUsingCache: (BOOL)shouldUseCache
|
||||
|
|
Loading…
Reference in a new issue