Skip to content

Commit

Permalink
fix: use main method instead of obejct
Browse files Browse the repository at this point in the history
  • Loading branch information
tassiluca committed Jan 10, 2024
1 parent 34d2180 commit 930ef23
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/main/scala/io/github/tassiLuca/gears/posts/UsePostsApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ package io.github.tassiLuca.gears.posts
import gears.async.{Async, Future}
import gears.async.default.given

object UsePostsApp extends App:
/* TODO WARNING: USING AN OBJECT WHICH EXTENDS `App` CAUSES STARVATION!
* THE WORKER THREAD GETS STUCK WAITING FOR THE RELEASE OF THE MONITOR LOCK
* waiting on the Class initialization monitor for io.github.tassiLuca.gears.posts.UsePostsApp$
* TO BE INVESTIGATED! */
@main def usePostsApp(): Unit =
val app = BlogPostsApp
Async.blocking:
val f = Future:
println("POST 1")
val f1 = Future:
println(s"POST 1 carried by ${Thread.currentThread()}")
app.postsService.create("ltassi@gmail.com", "A hello world post", "Hello World!")
// println(app.postsService.get("A hello world post"))
// val f2 = Future:
// println("POST 2")
// app.postsService.create("ltassi@gmail.com", "An another post", "Hello World 2!")
// println(app.postsService.get("An another post"))
// f1.await
// f2.await
println("End of the world...")
f.await
println("Ok")
println(app.postsService.get("A hello world post"))
val f2 = Future:
println(s"POST 2 carried by ${Thread.currentThread()}")
app.postsService.create("ltassi@gmail.com", "An another post", "Hello World 2!")
println(app.postsService.get("An another post"))
f1.await
f2.await

0 comments on commit 930ef23

Please sign in to comment.