Changeset 2384

Show
Ignore:
Timestamp:
02/15/06 12:22:40 (3 years ago)
Author:
jmorliaguet
Message:

- implemented storage access sequences (in write mode):

  • queue: first-in first-out
  • stack: last-in first-out
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js

    r2381 r2384  
    796796  // high-level I/O 
    797797  getData: function() { 
    798     this.storage.requestData(); /* asynchronous call */ 
     798    this.storage.readTransaction(); /* asynchronous call */ 
    799799    return this.storage.read(); 
    800800  }, 
    801801 
    802802  setData: function(data) { 
    803     this.storage.storeData(data); 
     803    this.storage.writeTransaction(data); 
    804804  }, 
    805805 
     
    872872    this.model = model; 
    873873    this.setup(); 
     874    this._queue = $A([]); 
     875    this._queued_data = $H({}); 
     876  }, 
     877 
     878  readTransaction: function(data) { 
     879    // TODO: implement a read access sequences 
     880    this.requestData(); 
     881  }, 
     882 
     883  writeTransaction: function(data) { 
     884    var access = this.model.def.storage.access; 
     885    if (access) { 
     886      switch (access.type) { 
     887        case 'queue': { 
     888          this._queue.push(data[access.signature]); 
     889          break; 
     890        } 
     891        case 'stack': { 
     892          this._queue.unshift(data[access.signature]); 
     893          break; 
     894        } 
     895      } 
     896    } 
     897    this.storeData(data); 
    874898  }, 
    875899 
     
    893917 
    894918  write: function(data) { 
     919    var access = this.model.def.storage.access; 
     920 
     921    if (access && access.type) { 
     922      var signature = data[access.signature]; 
     923      this._queued_data[signature] = data; 
     924      while (this._queue) { 
     925        var next = this._queue[0]; 
     926        if (next in this._queued_data) { 
     927          data = this._queued_data[next]; 
     928          this._writeFields(data); 
     929          this._queue.shift(); 
     930        } else { 
     931          break; 
     932        } 
     933      } 
     934    } else { 
     935      this._writeFields(data); 
     936    } 
     937  }, 
     938 
     939  _writeFields: function(data) { 
    895940    // filter out fields with the wrong data type 
    896941    var schema = this.model.schema; 
  • cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/cpsskins_latency.pt

    r2383 r2384  
    4646    function init() { 
    4747      run('no-sequence', 1); 
    48       run('stack-sequence', 2); 
    49       run('queue-sequence', 3); 
     48      run('queue-sequence', 2); 
     49      run('stack-sequence', 3); 
    5050    } 
    5151 
    5252    function run(model_id, storage) { 
    5353      var model = CPSSkins.getModelById(model_id); 
    54       $R(1,20).each(function(v) { 
     54      $R(1,10).each(function(v) { 
    5555        model.setData({'storage': storage, 'position': v, 's': v}); 
    5656      }); 
     
    167167           "type": "counter" 
    168168          }, 
    169          "model": "stack-sequence" 
     169         "model": "queue-sequence" 
    170170        } 
    171171        </ins> 
     
    177177           "type": "counter" 
    178178          }, 
    179          "model": "queue-sequence" 
     179         "model": "stack-sequence" 
    180180        } 
    181181        </ins>