A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Worried about a possbile race condition

Threaded View

  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.

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