Community
Participate
Working Groups
Copied from bug 116920 comment #34: Just stumbled upon this bug via Brad's blog. I like concurrency problems and I was looking over the Realm implementation. I just have one concern. It looks like the abstract impl of Realm doesn't have a consistent Exception handling strategy. There are two main entry points into Realm, asyncExec() and exec(). In exec(), if you are on the isCurrent() thread, the runnable is executed directly. If an exception happens here, it will spill out of the exec() method into the caller. If you are isCurrent(), it will async() the runnable. By it's vary nature, there can be no exception handling since it's executed on a different thread. It's nice that since you're dealing with Runnables they can't return a value. However, it might be important to know that the runnable actually did execute successfully. My suggestion is that you add the ability to register an "Exception handler" with the Realm. To be consistent, it should apply to both sync() and async() versions of execution. This will allow the caller to handle exceptions appropriately - at a minimum, they could log it. This could come in handy for the impl of DisplayRealm. So if a runtime exception happens during the runnable - it would just say "Unhandled exception occured while processing event loop" or whatever that message is.
Thanks for the suggestion. Makes sense - we should add API for this before M5.
Question: Should the exception handling be configurable per Realm instance, or per Runnable that you pass in?
Fixed >20070204.