The Artima Developer Community
Sponsored Link

Agile Buzz Forum
NetResources locking makeover

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
NetResources locking makeover Posted: Oct 30, 2005 5:29 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: NetResources locking makeover
Feed Title: Michael Lucas-Smith
Feed URL: http://www.michaellucassmith.com/site.atom
Feed Description: Smalltalk and my misinterpretations of life
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Michael Lucas-Smith

Advertisement

Bottom Feeder has had a few long standing issues with the feed update loop locking up or worse, one feeds contents appearing in another feed.

These issues, it is believed, were caused by NetResources, a library that has been built by myself and James Robertson for a few years now. It's basically a wrapper for all things HTTP.

Yesterday and Today I decided to clean up the way locking is handled in NetResources. That is, assuming of course, that it is NetResources that's causing the problems :) We'll certainly know for sure in the next few weeks.

The locking mechanisms have mostly been removed, opting instead of a ThreadSafeDictionary which ensures that only one process accesses/modifies it at a time. There is still a lock for HTTP access, but that's a RecursionLock so you won't see any stalling or locking any more from NetResources.

The HttpClientModel class in NetResourcesHTTP is not thread safe btw. Don't try to use it directly. Instead, use the NetResources API's that come on URI's, such as #asCacheItem, #asResource, #asUnreconciledCacheItem, etc.. they're detailed in the package comment.

This new version of NetResources also comes with a new feature. ResourceManager's. This is a bit of logic that used to be hidden away inside WithStyle's DownloadManager. What it does is that while ever it's active, accesses in to NetResources won't cause network activity after the first access of a resource.

For example, if I do 'http://www.w3.org' asURI asResource, the second time I call that NetResources will still do a HTTP access to the website. Often this results in a 304 Not Modified, but not always. So with a 'ResourceManager new active', the second access to the website would assume the in-memory contents of that resource are -valid and up to date-.

So a word of warning here.. only use it temporarily if you're going to use it at all. Also, be ware of leaking ResourceManager's. They live in your Process's environment dictionary, so if you are in the same process as WithStyle, you may end up accidently inheriting a resource manager you don't want. To ensure you're not doing that, make the following call 'self resourceManagerDo: [:manager | manager deactivate]'.

Don't worry about WithStyle when you do this, unless it's in the middle of downloading a web page - in which case you will generate more network activity than you intended. But the WithStyle engine will activate its resource manager whenever it decides to do some downloading.

But usually, you've got your own process separate from WithStyle, so this won't be an issue.

Read: NetResources locking makeover

Topic: Small may not be the answer Previous Topic   Next Topic Topic: Splogs explained

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use