dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Worried about a possbile race condition

  1. #1
    Retired SCORM Guru PAlexC's Avatar
    Join Date
    Nov 2000
    Location
    NJ
    Posts
    1,387

    Worried about a possbile race condition

    I'm a bit concerned that an app I'm working on may have a race condition that I won't be able to test.

    The main code looks like this:
    Code:
    wlc.scorm.LMSInitialize = function(p) { 
    	this.getAPI(p);
    	return this.API.LMSInitialize(p);
    };
    The getAPI funciton looks like this:
    Code:
    wlc.scorm.getAPI = function() {
    	
    	function searchWin(win) {
    		while((win.API == null) && (win.parent != null) && (win.parent != win) && (wlc.scorm.findAttempts <= wlc.scorm.findLimit)){
    			wlc.scorm.findAttempts++;
    			win = win.parent;
    		}
    		if (win.API != null) {
    			return win.API;
    		} else {
    			return null;
    		}	
    	}
    	
    	this.API = searchWin(window);		
    	if(	(this.API == null) && (window.opener != null) && (typeof(window.opener) != "undefined") ){
    		this.API = searchWin(window.opener);
    	}		
    	if(this.API == null) {
    		this.API = wlc.nullAPI;
    	}
    };
    I need to be absolutely sure that the 2nd statement in LMSInitialize won't execute until getAPI finishes executing.

    There's no way that could happen, right?
    Last edited by PAlexC; 10-09-2008 at 09:20 PM.
    "What really bugs me is that my mom had the audacity to call Flash Kit a bunch of 'inept jack-asses'." - sk8Krog
    ...and now I have tape all over my face.

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Yeah, you should be fine. The only problem would be if something asynchronous was happening in getAPI and it doesn't look like that's the case.

  3. #3
    Retired SCORM Guru PAlexC's Avatar
    Join Date
    Nov 2000
    Location
    NJ
    Posts
    1,387
    Thanks.

    It's hard to tell, because I can test this in any number of LMS's and it'll work fine, but inevitably there will be a client with a crappy LMS or infrastructure and it'll break inconsistently.

    The theory is, that the API should be launched and initialized by the LMS before the content is launched. Some LMS's don't do that, or have a bulky API written in Java that will still be initializing while the content is already loaded. Throw in a slow machine or network with a big API applet, and you can get inconsistent errors.
    "What really bugs me is that my mom had the audacity to call Flash Kit a bunch of 'inept jack-asses'." - sk8Krog
    ...and now I have tape all over my face.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center