MODULE; IMPORT FormsVBT, HashViewClass, VBT, View, Rd, Rsrc, Thread, ZeusPanel; <* FATAL FormsVBT.Error, FormsVBT.Unimplemented *> TYPE T = HashViewClass.T BRANDED OBJECT fv: FormsVBT.T; operations: CARDINAL; runtime: CARDINAL; OVERRIDES oeSetup := Setup; oeInsert := Operation; oeDelete := Operation; oeFind := Operation; oeCompare := Run1; oeAddToBucket := AddToBucket; oeDeleteFromBucket := DeleteFromBucket; oeCheckDeletable := Run1; oeCheckHashPosition := Run1; END; PROCEDURE HashStatsView Setup ( view: T; <* UNUSED *> data: FormsVBT.T; <* UNUSED *> nBuckets: INTEGER) = BEGIN view.operations := 0; view.runtime := 0; LOCK VBT.mu DO FormsVBT.PutInteger(view.fv, "Operations", 0); FormsVBT.PutInteger(view.fv, "Runtime", 0); END; END Setup; PROCEDUREOperation (view: T; <* UNUSED *> item: TEXT) = BEGIN LOCK VBT.mu DO INC(view.operations); FormsVBT.PutInteger(view.fv, "Operations", view.operations); END; END Operation; PROCEDURERun1 (view: T; <* UNUSED *> bucket: INTEGER) = BEGIN LOCK VBT.mu DO INC(view.runtime); FormsVBT.PutInteger(view.fv, "Runtime", view.runtime); END; END Run1; PROCEDUREAddToBucket ( view: T; <* UNUSED *> key: TEXT; <* UNUSED *> bucket: INTEGER) = BEGIN LOCK VBT.mu DO INC(view.runtime); FormsVBT.PutInteger(view.fv, "Runtime", view.runtime); END; END AddToBucket; PROCEDUREDeleteFromBucket ( view : T; <* UNUSED *> key : TEXT; <* UNUSED *> bucket : INTEGER; <* UNUSED *> markEmpty: BOOLEAN ) = BEGIN LOCK VBT.mu DO INC(view.runtime); FormsVBT.PutInteger(view.fv, "Runtime", view.runtime); END; END DeleteFromBucket; PROCEDURENew (): View.T = <* FATAL Rd.Failure, Rsrc.NotFound, Thread.Alerted *> BEGIN WITH view = NEW(T, fv := NEW(FormsVBT.T).initFromRsrc( "hashstats.fv", ZeusPanel.GetPath())) DO EVAL view.init(view.fv); RETURN view; END; END New; BEGIN ZeusPanel.RegisterView (New, "Stats", "Hash"); END HashStatsView.