~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/tcl/fca/fca-fcd.tcl

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 # fca-fcd.tcl --
  2 #
  3 #       Floor control dynamics
  4 #
  5 # Copyright (c) 1997-2002 The Regents of the University of California.
  6 # All rights reserved.
  7 #
  8 # Redistribution and use in source and binary forms, with or without
  9 # modification, are permitted provided that the following conditions are met:
 10 #
 11 # A. Redistributions of source code must retain the above copyright notice,
 12 #    this list of conditions and the following disclaimer.
 13 # B. Redistributions in binary form must reproduce the above copyright notice,
 14 #    this list of conditions and the following disclaimer in the documentation
 15 #    and/or other materials provided with the distribution.
 16 # C. Neither the names of the copyright holders nor the names of its
 17 #    contributors may be used to endorse or promote products derived from this
 18 #    software without specific prior written permission.
 19 #
 20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
 21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 23 # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 
 31 
 32 ########### FCAFloorInstance ########
 33 Class FCAFloorInstance
 34 FCAFloorInstance instproc init {} {
 35     $self next
 36     $self set grantSeq_ 0
 37     $self set srcId_ ""
 38     $self set requestId_ ""
 39 }
 40 
 41 
 42 FCAFloorInstance instproc evacuate {} {
 43     $self set grantSeq_ 0
 44     $self set srcId_ ""
 45     $self set requestId_ ""
 46 }
 47 
 48 
 49 FCAFloorInstance instproc srcId {} {
 50     return [$self set srcId_]
 51 }
 52 
 53 
 54 FCAFloorInstance instproc requestId {} {
 55     return [$self set requestId_]
 56 }
 57 
 58 
 59 FCAFloorInstance instproc isGrant {} {
 60     #return [$self set isGrant_]
 61     if { [$self set srcId_]=={} } {
 62         return 0
 63     } else {
 64         return 1
 65     }
 66 }
 67 
 68 
 69 FCAFloorInstance instproc grantSeq {} {
 70     return [$self set grantSeq_]
 71 }
 72 
 73 
 74 ########### FCAFloor ################
 75 Class FCAFloor -superclass FCAFloorConfig
 76 FCAFloor instproc init {floorType maxHldrs} {
 77     $self next $floorType $maxHldrs
 78     $self instvar floorInstances_
 79     for {set i 0} {$i < $maxHldrs} {incr i 1 } {
 80         set floorInstances_($i) [new FCAFloorInstance]
 81     }
 82 }
 83 
 84 
 85 #FCAFloor instproc evacuate { instance } {
 86 #    $self instvar floorInstances_
 87 #    $floorInstances_($instance) evacuate
 88 #}
 89 
 90 FCAFloor instproc evacuate {} {
 91     $self instvar floorInstances_ maxHldrs_
 92     for {set i 0} {$i < $maxHldrs_ } {incr i 1} {
 93         $floorInstances_($i) evacuate
 94     }
 95 }
 96 
 97 # return free instance number if one is avail, else return -1
 98 FCAFloor instproc getFreeInstance {} {
 99     $self instvar floorInstances_ maxHldrs_
100     for {set i 0} {$i < $maxHldrs_} {incr i 1} {
101         if { [info exist floorInstances_($i)]} {
102             return $i
103         }
104     }
105     return -1
106 }
107 
108 
109 FCAFloor instproc floorInstances {} {
110     return [$self set floorInstances_]
111 }
112 
113 
114 #FCAFloor instproc getLastGrantSeq {instance} {
115 #    $self instvar floorInstances_
116 #    return [$floorsInstances_($instance) set grantSeq_]
117 #}
118 
119 #FCAFloor instproc getIsGrant {instance} {
120 #    $self instvar floorInstances_
121 #    return [$floorsInstances_($instance) set isGrant_]
122 #}
123 
124 # return floorInstance of srcId, -1 for not existing
125 #FCAFloor instproc floorInstance { srcId } {
126 #    $self instvar floorInstances_ maxHldrs_
127 #    for {set i 0} {$i < $maxHldrs_} {incr i 1} {
128 #       if {[$hldrIds_($i) set srcId_] == $srcId}{
129 #           return $i
130 #       }
131 #    }
132 #    return -1
133 #}
134 
135 
136 FCAFloor instproc getFloorInstance { instance } {
137     if { ($instance < [$self set maxHldrs_]) && ($instance >= 0)} {
138         return [$self set floorInstances_($instance)]
139     } else {
140         return ""
141     }
142 }
143 
144 
145 FCAFloor instproc get_holder {instanceNum srcIdVar requestIdVar} {
146     $self instvar floorInstances_ maxHldrs_
147     upvar $srcIdVar srcId
148     upvar $requestIdVar requestId
149 
150     if { ($maxHldrs_ > $instanceNum) && ($instanceNum >= 0) } {
151         set srcId [$floorInstances_($instanceNum) set srcId_]
152         set requestId [$floorInstances_($instanceNum) set requestId_]
153     } else {
154         set srcId ""
155         set requestId ""
156     }
157 }
158 
159 
160 # returns the floor instance if the request exists; -1 otherwise
161 FCAFloor instproc request_exists {srcId requestId} {
162     $self instvar floorInstances_ maxHldrs_
163     for { set i 0 } { $i < $maxHldrs_ } { incr i } {
164         if { [$floorInstances_($i) set srcId_]==$srcId &&
165         [$floorInstances_($i) set requestId_]==$requestId } {
166             return $i
167         }
168     }
169     return -1
170 }
171 
172 
173 # return true(1) if successful
174 FCAFloor instproc grant_floor {instanceNum srcId requestId grantSeq} {
175     $self instvar floorInstances_ maxHldrs_
176     if { ($maxHldrs_ > $instanceNum) && ($instanceNum >= 0) } {
177         $floorInstances_($instanceNum) set srcId_ $srcId
178         $floorInstances_($instanceNum) set requestId_ $requestId
179         $floorInstances_($instanceNum) set grantSeq_ $grantSeq
180         #$floorInstances_($instanceNum) set isGrant_  1
181         return 1
182     }
183     DbgOut "Error, no such instance ($instanceNum) exists for this floor"
184     return 0
185 }
186 
187 
188 FCAFloor instproc release_floor {instanceNum} {
189     $self instvar floorInstances_ maxHldrs_
190     if { ($maxHldrs_ > $instanceNum) && ($instanceNum >= 0) } {
191         $floorInstances_($instanceNum) set srcId_ ""
192         $floorInstances_($instanceNum) set requestId_ ""
193         #$floorInstances_($instanceNum) set isGrant_ 0
194     }
195 }
196 
197 
198 
199 # return 0 if successful
200 #FCAFloor instproc releaseHolder {instance grantSeq} {
201 #    $self instvar floorInstances_ maxHldrs_
202 #    if { ($maxHldrs_ > $instanceNum) && ( $instanceNum >=0 ) } {
203 #       if {[$floorInstances_($instanceNum) set grantSeq_] != $grantSeq} {
204 #           $floorInstances_($instanceNum) set isGrant_ 0
205 #           return 1
206 #       } else {
207 #           DbgOut "this proc shouldn't be called, seq no mismatch"
208 #       }
209 #    }
210 #    DbgOut "Error, no such instance ($instanceNum) exists for this floor"
211 #    return 0
212 #}
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 Class FCA_RequestList
223 
224 
225 FCA_RequestList instproc init { } {
226     $self next
227     $self set list_ {}
228 }
229 
230 
231 FCA_RequestList instproc add { srcId requestId } {
232     $self instvar list_
233     lappend list_ "$srcId+$requestId"
234     DbgOut "Appending $srcId:$requestId to list_: $list_"
235 }
236 
237 
238 FCA_RequestList instproc remove_top { srcIdVar requestIdVar } {
239     upvar $srcIdVar srcId
240     upvar $requestIdVar requestId
241     $self instvar list_
242 
243     set id [lindex $list_ 0]
244     set list_ [lreplace $list_ 0 0]
245     set id [split $id "+"]
246     set srcId [lindex $id 0]
247     set requestId [lindex $id 1]
248 }
249 
250 
251 FCA_RequestList instproc get_list {} {
252     $self instvar list_
253     set returnlist ""
254     foreach item $list_ {
255         set newItem [split $item "+"]
256         lappend returnlist $newItem
257     }
258     return $returnlist
259 }
260 
261 
262 FCA_RequestList instproc remove { srcId requestId } {
263     $self instvar list_
264     set idx [lsearch $list_ $srcId+$requestId]
265     if { $idx!=-1 } {
266         set list_ [lreplace $list_ $idx $idx]
267         return 1
268     } else {
269         return 0
270     }
271 }
272 
273 
274 
275 FCA_RequestList instproc exists { srcId requestId } {
276     $self instvar list_
277     DbgOut "Searching for existence of $srcId:$requestId in list_: $list_"
278     if { [lsearch $list_ "$srcId+$requestId"] != -1 } {
279         return 1
280     } else {
281         return 0
282     }
283 }
284 
285 
286 FCA_RequestList instproc count { } {
287     $self instvar list_
288     return [llength $list_]
289 }
290 
291 
292 Class FCA_RequestList/Bounded -superclass FCA_RequestList
293 
294 
295 FCA_RequestList/Bounded instproc init { fcp } {
296     $self next
297     $self set fcp_ $fcp
298 }
299 
300 
301 FCA_RequestList/Bounded instproc is_full { } {
302     $self instvar list_ fcp_
303     if { [llength $list_] < [$fcp_ maxRqs] } {
304         return 0
305     }
306     return 1
307 }
308 
309 
310 FCA_RequestList/Bounded instproc avail_space {} {
311     $self instvar list_ fcp_
312     return [expr [$fcp_ maxRqs] - [llength $list_]]
313 }
314 
315 
316 
317 
318 
319 
320 
321 
322 
323 
324 
325 
326 
327 
328 
329 # DATA MEMBERS of Class FCAFloorDynamics
330 # mgr_    : FCA manager for the instance of FCAFloorDynamics
331 # floors_    : of class FCAFloor -- list of floors
332 # admittedRequests_: list of FCA_RequestList/Bounded
333 # pendingRequests_: list of FCA_RequestList
334 # fcp_    : floor control policy for this session
335 # moderatorIds_: list of chairs ids (list of uid and addr) { {uid addr} ... }
336 # MEMBER FUNCTIONS:
337 # isChair $uid $addr, setRqQsize $qsize, matchfid $fid, fl $fid,
338 # removeHolder $fid $uid $addr
339 # newRq $fid $rq
340 # replaceHolder $fid $olduid $oldaddr $newuid $newaddr
341 
342 Class FCAFloorDynamics
343 FCAFloorDynamics instproc init {mgr fcp moderatorIds} {
344     $self next
345     $self instvar mgr_ fcp_ floors_ admittedRequests_ pendingRequests_ \
346             moderatorIds_
347     #set curStateNum_ 0
348     set topGrantSeq_ 0
349     set mgr_ $mgr
350     set fcp_ $fcp
351     set moderatorIds_ $moderatorIds
352     set admittedRequests_ [new FCA_RequestList/Bounded $fcp]
353     set pendingRequests_  [new FCA_RequestList]
354     #set canceledRequests_ [new FCA_RequestList]
355 
356     foreach i [$fcp_ floorConfigs] {
357         puts "$i"
358         set floors_([$i floorType]) [new FCAFloor [$i floorType] [$i maxHldrs]]
359     }
360 
361 
362     $self set curModeratorState_ 0
363 }
364 
365 
366 FCAFloorDynamics instproc reset {} {
367     $self instvar floors_ fcp_
368     set ftypes [$fcp_ floorTypes]
369     foreach f $ftypes {
370         $floors_($f) evacuate
371     }
372 }
373 
374 
375 FCAFloorDynamics instproc admitted_requests {} {
376     return [$self set admittedRequests_]
377 }
378 
379 
380 FCAFloorDynamics instproc maxInstanceNum { floorType } {
381     $self instvar fcp_
382     return [$fcp_ getMaxHdlrs $floorType]
383 }
384 
385 
386 # return fcaPkt of type PKT_GRANT_UPDATE
387 FCAFloorDynamics instproc make_grant_pkt {} {
388     $self instvar floors_
389     set fcaPkt [new FCA_Packet]
390     $fcaPkt set pktType "PKT_GRANT_UPDATE"
391     $fcaPkt set moderatorState [$self moderator_state]
392     $fcaPkt set pktUpdates ""
393     set numUpdates 0
394     set ftypes [array names floors_]
395     foreach ftype $ftypes {
396         set floor $floors_($ftype)
397         set maxInstanceNum [$self maxInstanceNum $ftype]
398 
399         for {set instanceNum 0} {$instanceNum < $maxInstanceNum } \
400                 { incr instanceNum 1 } {
401             set instance [$self getFloorInstanceObj $ftype $instanceNum]
402             if {[$instance srcId] != ""} {
403                 incr numUpdates 1
404                 set pktUpdate [new FCA_Packet]
405                 $pktUpdate set srcId [$instance srcId]
406                 $pktUpdate set grantSeqno [$instance grantSeq]
407                 $pktUpdate set requestId [$instance requestId]
408                 $pktUpdate set floorType [$floor floorType]
409                 $pktUpdate set floorInstance $instanceNum
410                 $fcaPkt lappend pktUpdates $pktUpdate
411             }
412         }
413     }
414     $fcaPkt set numUpdates $numUpdates
415     return $fcaPkt
416 }
417 
418 
419 FCAFloorDynamics instproc make_queue_pkt {} {
420     $self instvar admittedRequests_
421 
422     set fcaPkt [new FCA_Packet]
423     $fcaPkt set pktType "PKT_QUEUE_UPDATE"
424     $fcaPkt set pktUpdates ""
425     $fcaPkt set moderatorState [$self moderator_state]
426     set admittedList [$admittedRequests_ get_list]
427     $fcaPkt set numUpdates [llength admittedList]
428     foreach rq $admittedList {
429         set pktUpdate [new FCA_Packet]
430         $pktUpdate set srcId [lindex $rq 0]
431         $pktUpdate set requestId [lindex $rq 1]
432         $pktUpdate set isAdd 1
433         $fcaPkt lappend pktUpdates $pktUpdate
434     }
435     return $fcaPkt
436 }
437 
438 
439 
440 FCAFloorDynamics instproc getFloorInstanceObj { ftype instance } {
441     $self instvar floors_ fcp_
442     if { ![info exist floors_($ftype)] } {
443         DbgOut "$ftype floor type doesn't exist"
444         return ""
445     }
446 
447     set instObj [$floors_($ftype) getFloorInstance $instance]
448     if { $instObj!={} } {
449         return $instObj
450     }
451     DbgOut "Floor instance doesn't exist"
452     return ""
453 }
454 
455 
456 FCAFloorDynamics instproc isRequestQFull {} {
457     $self instvar admittedRequests_
458     return [$admittedRequests_ is_full]
459 }
460 
461 
462 FCAFloorDynamics instproc numRequests {} {
463     $self instvar admittedRequests_
464     return [$admittedRequests_ count]
465 }
466 
467 
468 
469 FCAFloorDynamics instproc avail_requestQ_space {} {
470     $self instvar admittedRequests_
471     return [$admittedRequests_ avail_space]
472 }
473 
474 
475 # return boolean indicating whether successful
476 FCAFloorDynamics instproc admit_request { srcId requestId } {
477     $self instvar admittedRequests_
478 
479     DbgOut "Admitting request $srcId:$requestId"
480     $admittedRequests_ add $srcId $requestId
481 
482     # add to the ui as well, if we have the actual request
483     $self instvar mgr_
484     set allRequests [[$mgr_ getRcvr $srcId] get_requests]
485     if { [$allRequests have $requestId] } {
486         [$mgr_ uiMgr] add_admit [$allRequests get $requestId]
487     }
488 }
489 
490 
491 # return boolean to indicate whether changed fcd
492 FCAFloorDynamics instproc remove_admitted_request {srcId requestId} {
493     $self instvar admittedRequests_
494     if { ![$admittedRequests_ remove $srcId $requestId] } {
495         DbgOut "Could not remove $srcId:$requestId from admitted requests"
496         return 0
497     }
498 
499     # remove from the ui as well, if we have the actual request
500     $self instvar mgr_
501     set allRequests [[$mgr_ getRcvr $srcId] get_requests]
502     if { [$allRequests have $requestId] } {
503         [$mgr_ uiMgr] remove_admit [$allRequests get $requestId]
504     } else {
505         DbgOut "Don't have $srcId:$requestId"
506     }
507 
508     return 1
509 }
510 
511 
512 # get floor request that ask for ftype and instance, not removed from list
513 #FCAFloorDynamics instproc getFloorRequest { ftype instance } {
514 #    $self instvar admittedRequests_
515 #    foreach i $admittedRequests_ {
516 #       if {($ftype == [$i set floorType_]) && \
517 #               ($instance == [$i set floorInstance_])} {
518 #           return $i
519 #       }
520 #    }
521 #    return ""
522 #}
523 
524 # first item in the queue is returned and dequeued
525 #FCAFloorDynamics instproc nextFloorRequest {} {
526 #    $self instvar admittedRequests_
527 #    if { [llength $admittedRequests_] == 0 } {
528 #       DbgOut "There is no floor requests. "
529 #       return ""
530 #    }
531 #    set rqst [lindex $admittedRequests_ 0 0]
532 #    set admittedRequests_ [lreplace $admittedRequests_ 0 0]
533 #    return $rqst
534 #}
535 
536 
537 # first item in the queue is returned and dequeued
538 #FCAFloorDynamics instproc next_pending_request {} {
539 #    $self instvar pendingRequests_
540 #
541 #    $pendingRequests_ remove_head srcId requestId
542 #    if { $srcId=={} || $requestId=={} } {
543 #       DbgOut "Could not get any request from the pending queue"
544 #       return ""
545 #    }
546 #
547 #    set rcvr [$mgr_ getRcvr $srcId]
548 #    if { $rcvr=={} } {
549 #       DbgOut "Could not find receiver object for $srcId"
550 #       return ""
551 #    }
552 #    return [$rcvr get_request $requestId]
553 #}
554 
555 
556 
557 FCAFloorDynamics instproc isPendingRequest {srcId rqId} {
558     $self instvar pendingRequests_
559     return [$pendingRequests exists $srcId $rqId]
560 }
561 
562 
563 # return 1 if changed fcd
564 FCAFloorDynamics instproc new_pending_request {rq} {
565     $self instvar pendingRequests_
566 
567     $pendingRequests_ add [$rq srcId] [$rq requestId]
568 
569     $self instvar mgr_
570     [$mgr_ uiMgr] add_pending $rq
571 }
572 
573 
574 # return 1 if changed fcd
575 FCAFloorDynamics instproc delete_pending_request {srcId rqId} {
576     $self instvar pendingRequests_ mgr_
577     $self instvar remove $srcId $rqId
578 
579     if { ![$pendingRequests_ remove $srcId $rqId] } {
580         DbgOut "Could not remove $srcId:$rqId from admitted requests"
581         return 0
582     }
583 
584     set allRequests [[$mgr_ getRcvr $srcId] get_requests]
585     if { [$allRequests have $rqId] } {
586         [$mgr_ uiMgr] remove_pending [$allRequests get $rqId]
587     }
588     return 1
589 }
590 
591 
592 #FCAFloorDynamics instproc getLastGrantSeq {ftype instance} {
593 #    $self instvar floors_
594 #    return [$floors_($ftype) getLastGrantSeq $instance]
595 #}
596 
597 #FCAFloorDynamics instproc getIsGrant {instance} {
598 #    $self instvar floors_
599 #    return [$floors_($ftype) getIsGrant $instance]
600 #}
601 
602 # return instance number or -1 if none avail
603 FCAFloorDynamics instproc getFreeInstance {ftype} {
604     $self instvar floors_
605     return [$floors_($ftype) getFreeInstance]
606 }
607 
608 
609 FCAFloorDynamics instproc cancel_request_if_done { srcId requestId } {
610     $self instvar mgr_ fcp_ floors_
611 
612     foreach fconfig [$fcp_ floorConfigs] {
613         if { [$floors_([$fconfig floorType]) request_exists $srcId \
614                 $requestId] != -1 } {
615             # this request still exists
616             return
617         }
618     }
619 
620     set allRequests [[$mgr_ getRcvr $srcId] get_requests]
621     $allRequests cancel $requestId
622 }
623 
624 
625 # return 1 if successful
626 FCAFloorDynamics instproc grant_floor {ftype instance srcId requestId \
627         grantSeq} {
628     $self instvar floors_ mgr_
629     $floors_($ftype) get_holder $instance oldSrcId oldRequestId
630 
631     DbgOut "About to grant the floor"
632     if { ![$floors_($ftype) grant_floor $instance $srcId $requestId \
633             $grantSeq]} {
634         return 0
635     }
636 
637     if { $oldSrcId!="" && $oldRequestId!="" } {
638         $self cancel_request_if_done $oldSrcId $oldRequestId
639     }
640     DbgOut "Trying to remove admitted request"
641     $self remove_admitted_request $srcId $requestId
642 
643     [$mgr_ uiMgr] grant_received $ftype [$self getFloorInstanceObj \
644             $ftype $instance]
645     return 1
646 }
647 
648 
649 
650 FCAFloorDynamics instproc release_floor {ftype instance} {
651     $self instvar floors_ mgr_
652 
653     $floors_($ftype) evacuate $instance
654     [$mgr_ uiMgr] release_received $ftype $instance
655 }
656 
657 
658 # return 0 if successful
659 FCAFloorDynamics instproc releaseHolder {ftype instance grantSeq} {
660     $self instvar floors_
661     return [$floors_($ftype) releaseHolder $instance $grantSeq]
662 }
663 
664 
665 
666 
667 
668 Class FCAFloorDynamics/Moderator -superclass FCAFloorDynamics
669 
670 FCAFloorDynamics/Moderator instproc init { mgr fcp moderatorIds } {
671     $self next $mgr $fcp $moderatorIds
672 }
673 
674 
675 
676 
677 
678 FCAFloorDynamics instproc moderator_state { } {
679     return [$self set curModeratorState_]
680 }
681 
682 
683 FCAFloorDynamics instproc incr_moderator_state { } {
684     $self instvar curModeratorState_
685     incr curModeratorState_
686     return $curModeratorState_
687 }
688 
689 
690 FCAFloorDynamics instproc set_moderator_state { value } {
691     $self set curModeratorState_ $value
692 }
693 
694 
695 # GR--Grant or Release
696 FCAFloorDynamics instproc gr_is_stale {floorType instance grantSeq} {
697     set instObj [$self getFloorInstanceObj $floorType $instance]
698 
699     set lastGrant [$instObj grantSeq]
700     if { $grantSeq > $lastGrant } {
701         # definitely not stale
702         return 0
703     }
704     if {$grantSeq < $lastGrant} {
705         return 1
706     }
707 
708     # the two seqnos are the same
709     if { [$instObj isGrant] } {
710         return 0
711     } else {
712         return 1
713     }
714 }
715 
716 
717 
718 
719 FCAFloorDynamics instproc handle_floor_request { request } {
720     # I am a participant; check if this request has been admitted
721     # if so, add it to the ui
722 
723     $self instvar admittedRequests_
724     if { [$admittedRequests_ exists [$request srcId] [$request requestId]] } {
725         $self instvar mgr_
726         [$mgr_ uiMgr] add_admit $request
727     }
728 }
729 
730 
731 FCAFloorDynamics/Moderator instproc handle_floor_request { request } {
732     $self admit_request [$request srcId] [$request requestId]
733 
734     # this request gets admitted
735     set state [$self incr_moderator_state]
736 
737     $self instvar mgr_
738     set localRcvr [$mgr_ localRcvr]
739     set isAdd 1
740     $localRcvr sendQueueUpdate $isAdd [subst {{[$request srcId] \
741             [$request requestId]}}] $state
742 }
743 
744 
745 FCAFloorDynamics instproc handle_floor_cancel { srcId requestId \
746         needQueueUpdate } {
747     # the cancel might be for an already granted request
748     # in that case release the grant!
749 
750     $self instvar mgr_ fcp_ floors_
751 
752     foreach fconfig [$fcp_ floorConfigs] {
753         set instance [$floors_([$fconfig floorType]) request_exists $srcId \
754                 $requestId]
755         if { $instance!=-1 } {
756             # this request exists; release this floor
757             $floors_([$fconfig floorType] release_floor $instance
758         }
759     }
760 }
761 
762 
763 FCAFloorDynamics/Moderator instproc handle_floor_cancel { srcId requestId \
764         needQueueUpdate } {
765     $self instvar mgr_
766     $self next $srcId $requestId $needQueueUpdate
767     if { $needQueueUpdate==1 } {
768         set isAdd 0
769         set state [$self incr_moderator_state]
770         [$mgr_ localRcvr] sendQueueUpdate $isAdd \
771                 [subst {{$srcId $requestId}}] $state
772     }
773 }
774 
775 
776 # return boolean indicating whether the request was deleted or not
777 FCAFloorDynamics instproc delete_request { srcId requestId } {
778     $self instvar admittedRequests_ pendingRequests_ mgr_
779     if { [$admittedRequests_ exists $srcId $requestId] } {
780         $self remove_admitted_request $srcId $requestId
781     } elseif { [$pendingRequests_ exists $srcId $requestId] } {
782         $self delete_pending_request $srcId $requestId
783     } else {
784         DbgOut "Huh! We are trying to cancel a request that is neither in the"
785         DbgOut "admitted list nor in the pending list"
786         return 0
787     }
788 
789     if { [[$mgr_ localRcvr] srcId] == $srcId } {
790         # I am cancelling my own request; I should buffer this event until the
791         # moderator gets it
792         $canceledRequests_ add $srcId $requestId
793     }
794     return 1
795 }
796 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.