Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bugs in concurrency chapter, "A solution: Producer/Consumer" section #124

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

prafulliu
Copy link

At the end of the _concurrency_ chapter, there is a demo named _A solution: Producer/Consumer_ has some bugs.

I also fixed them in Russian, Korea and Chinese.

val queue = new LinkedBlockingQueue[String]()    

But the other code use q for this instance, so it's an error.
2.

for (i <- i to cores) {

The second i is error, it should be 1.
3.

pool.submit(new IndexerConsumer[String](index, q))

index is not declared.

class Producer[T](path: String, queue: BlockingQueue[T]) extends Runnable {
  def run() {
    Source.fromFile(path, "utf-8").getLines.foreach { line =>
      queue.put(line)
    }
  }
}
val q = new LinkedBlockingQueue[String]()
val producer = new Producer[String]("users.txt", q)

queue.put(line) in Producer class will call an error.

error: type mismatch;
 found   : String("sssssssssss")
 required: T
    b.tell("sssssssssss")
               ^
one error found

Change it to

class Producer[T>:String](path: String, queue: BlockingQueue[T]) extends Runnable {

or

class Producer[T](path: String, queue: BlockingQueue[String]) extends Runnable {

can fix it.

…gnostic RPC System" is expired, I changed it to the new link in twitter's Engineering Blog. Also in other languages' translation.
@prafulliu
Copy link
Author

fix link error in Finagle chapter, A link to "Finagle: A Protocol-Agnostic RPC System" is expired, I changed it to the new link in twitter's Engineering Blog. Also in other languages' translation.

@CLAassistant
Copy link

CLAassistant commented Jul 18, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants