Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
package threadpool
// Callable the tasks which returns the output after exit should implement this interface
type Callable interface {
Call() interface{}
}
// Future is the handle returned after submitting a callable task to the thread threadpool
type Future struct {
response chan interface{}
done bool
}
// callableTask is internally used to wrap the callable and future together
// So that the worker can send the response back through channel provided in Future object
type callableTask struct {
Task Callable
Handle *Future
}
// Get returns the response of the Callable task when done
// Is is the blocking call it waits for the execution to complete
func (f *Future) Get() interface{} {
return <-f.response
}
// IsDone returns true if the execution is already done
func (f *Future) IsDone() bool {
return f.done
}
// Runnable is interface for the jobs that will be executed by the threadpool
type Runnable interface {
Run()
}