Skip to content

Commit 177a285

Browse files
Updated fcfs scheduler
1 parent bcb031c commit 177a285

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

internal/scheduler/fcfs/fcfs.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import (
1515
func NewFCFSScheduler(sm *session.Manager, processor transprocessor.TransactionProcessor) *FCFSScheduler {
1616
/* calculate max workers */
1717
maxProcs := runtime.GOMAXPROCS(0)
18-
maxWorkers := config.BackendConfig.AppInfo.MaxWorkers
18+
maxWorkers := config.BackendConfig.AppInfo.MaxWorkers
1919

20-
/*
21-
incase of maxWorkers set less than or equal to 0,
22-
use 75% of GOMAXPROCS to prevent starvation to other processes
20+
/*
21+
incase of maxWorkers set less than or equal to 0,
22+
use 75% of GOMAXPROCS to prevent starvation to other processes
2323
*/
2424
if maxWorkers <= 0 {
2525
maxWorkers = int(float64(maxProcs) * 0.75)
@@ -32,9 +32,9 @@ func NewFCFSScheduler(sm *session.Manager, processor transprocessor.TransactionP
3232

3333
return &FCFSScheduler{
3434
curSessionManager: sm,
35-
maxWorkers: maxWorkers,
36-
semaphore: make(chan struct{}, maxWorkers),
37-
processor: processor,
35+
maxWorkers: maxWorkers,
36+
semaphore: make(chan struct{}, maxWorkers),
37+
processor: processor,
3838
}
3939
}
4040

@@ -50,14 +50,14 @@ func (f *FCFSScheduler) Run(ctx context.Context) error {
5050
/* in case default is working hard - ctx is passed here so it must attempt to quit */
5151
default:
5252
/* RULE: ctx is propogates all over the coming functions */
53-
53+
5454
/* get next session in the queue (round robin manner) */
5555
curSession := f.curSessionManager.GetNextSession()
5656
if curSession == nil {
5757
/* might need a delay of 10 ms */
5858
continue
5959
}
60-
60+
6161
/* check if transaction queue of the session is empty */
6262
curSession.Mutex.Lock()
6363
if curSession.TransactionQueue.Len() == 0 {
@@ -77,18 +77,18 @@ func (f *FCFSScheduler) Run(ctx context.Context) error {
7777
/* defer clearing the semaphore channel */
7878
defer func() { <-f.semaphore }()
7979

80-
/*
81-
process the transaction
80+
/*
81+
process the transaction
8282
* processTransaction handles transaction processing completely
8383
* now it is responsible now responsible to execute it
8484
* role of scheduler in handling transactions ends here
8585
*/
8686
if err := f.processor.Process(ctx, curSession, transaction); err != nil {
87-
zap.L().Error("Faild to process transaction",
87+
zap.L().Error("Failed to process transaction",
8888
zap.Error(err),
8989
)
9090
}
9191
}(curSession, transaction)
9292
}
93-
}
93+
}
9494
}

0 commit comments

Comments
 (0)