vivekvardha / TaskSchedulingAssignment

Attempted to implement code using channel and go routines which mimics priority based scheduling
0 stars 0 forks source link

Using same go routine to push and pop #3

Open hariprasadraja opened 3 years ago

hariprasadraja commented 3 years ago

Can you do push and pop with separate go routine ?

            // Popping will lead to removal of task as per the priority
            jobs <- heap.Pop(&pq).(Task)
vivekvardha commented 3 years ago

So the intention of poping out from same go routine is that I want to do the communication with "executeTask" goroutine using channel. If I wouldn't have popped over here, another approach would have been popping out tasks in "executeTask" go routine itself but in this case I would have required to use mutex for guarding pq and drop the usage of channel.

hariprasadraja commented 3 years ago

What operation you are going to perform after pop and before push is the key thing. execute task does justify it's responsibility.