package main
import (
"fmt"
"time"
)
type ClientOrder2 struct {
Order_id int
Account_id string
Currency_symbol string
Pricevalue float32
SellorBuystatus string
}
var orders2 = []ClientOrder2{
ClientOrder2{
Order_id: 1,
Account_id: "yesh123",
Currency_symbol: "USD/EUR",
Pricevalue: 70.001,
SellorBuystatus: "sell",
},
ClientOrder2{
Currency_symbol: "USD/INR",
Pricevalue: 70.002,
},
ClientOrder2{
Currency_symbol: "USD/EUR",
Pricevalue: 71.003,
},
ClientOrder2{
Currency_symbol: "USD/EUR",
Pricevalue: 70.001,
},
}
func compcurrency(id string, jobs <-chan string, results chan<- string) <-chan string {
put := make(chan string, 4)
go func() {
for j := range jobs {
for i := 0; i < 4; i++ {
put <- j
}
fmt.Println("comparing pricevalues", id, "Market open:", j)
time.Sleep(time.Second)
results <- j
}
}()
return put
}
func comppricevalue(id float32, jobs1 <-chan float32, results1 chan<- float32) <-chan float32 {
putt := make(chan float32, 4)
go func() {
for k := range jobs1 {
for i := 0; i < 4; i++ {
putt <- k
}
fmt.Println("comparing pricevalues", id, "Market open:", k)
time.Sleep(time.Second)
results1 <- k
}
}()
return putt
}
func main() {
fmt.Println("program starting")
fmt.Println(orders2)
job := make(chan string, 3)
result := make(chan string, 3)
for w := "a"; w <="f"; {
go compcurrency(w, job, result)
}
for j := 1; j <= 9; j++ {
job <- j
}
close(job)
for a := 1; a <= 9; a++ {
<-result
}
job1 := make(chan float32, 3)
result1 := make(chan float32, 3)
for x := 1; x <= 2; x++ {
go comppricevalue(x, job1, result1)
}
for k := 1; k <= 9; k++ {
job1 <- k
}
close(job1)
for a := 1; a <= 9; a++ {
<-result1
}
}