All pastes #2050809 Raw Edit

Miscellany

public text v1 · immutable
#2050809 ·published 2011-04-26 09:53 UTC
rendered paste body
(is_opened, cur_fid) := (0, 0);

for(;;) alt {
(nil,count,fid,reply) := <-fio.read =>
        if(reply == nil)
                if(is_opened && cur_fid == fid)
                        is_opened = 0;
                else
                        break;
        else        
                if(!is_opened){
                        is_opened = 1;
                        cur_fid = fid;
                }
                else if(cur_fid != fid){
                        reply <-= (nil, "file already in use");
                        break;
                }

        REAL_WORK_HERE
}