Permalink
Browse files

Init

  • Loading branch information...
sndyuk committed Dec 30, 2012
1 parent d565b93 commit e3acc52583d1f075ff86e1e8cd1769f20a41700d
View
@@ -10,4 +10,28 @@ project/boot/
project/plugins/project/
# Scala-IDE specific
-.scala_dependencies
+.scala_dependencies
+
+logs
+project/project
+project/target
+target
+tmp
+.history
+dist
+/.idea
+/*.iml
+/out
+/.idea_modules
+/.classpath
+/.project
+/RUNNING_PID
+
+# Sublime Text 2
+*.sublime-project
+*.sublime-workspace
+
+.cache
+.settings/
+.target/
+.DS_Store
@@ -0,0 +1,26 @@
+# In this file you can override any option defined in the reference files.
+# Copy in parts of the reference files and modify as you please.
+akka {
+ # Event handlers to register at boot time (Logging$DefaultLogger logs to STDOUT)
+ event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
+ # Log level used by the configured loggers (see "event-handlers") as soon
+ # as they have been started; before that, see "stdout-loglevel"
+ # Options: ERROR, WARNING, INFO, DEBUG
+ loglevel = DEBUG
+ # Log level for the very basic logger activated during AkkaApplication startup
+ # Options: ERROR, WARNING, INFO, DEBUG
+ stdout-loglevel = DEBUG
+
+ actor {
+ default-dispatcher {
+ # Throughput for default Dispatcher, set to 1 for as fair as possible
+ throughput = 10
+ }
+ }
+ remote {
+ server {
+ # The port clients should connect to. Default is 2552 (AKKA)
+ port = 2562
+ }
+ }
+}
@@ -0,0 +1,14 @@
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="debug">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
@@ -0,0 +1,22 @@
+package jp.enrapt.margx
+import com.typesafe.scalalogging.slf4j.Logging
+
+object Runner extends App with Logging {
+
+ logger.debug(
+ """
+ | .----------------. .----------------. .----------------. .----------------. .----------------.
+ || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |
+ || | ____ ____ | || | __ | || | _______ | || | ______ | || | ____ ____ | |
+ || ||_ \ / _|| || | / \ | || | |_ __ \ | || | .' ___ | | || | |_ _||_ _| | |
+ || | | \/ | | || | / /\ \ | || | | |__) | | || | / .' \_| | || | \ \ / / | |
+ || | | |\ /| | | || | / ____ \ | || | | __ / | || | | | ____ | || | > `' < | |
+ || | _| |_\/_| |_ | || | _/ / \ \_ | || | _| | \ \_ | || | \ `.___] _| | || | _/ /'`\ \_ | |
+ || ||_____||_____|| || ||____| |____|| || | |____| |___| | || | `._____.' | || | |____||____| | |
+ || | | || | | || | | || | | || | | |
+ || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |
+ | '----------------' '----------------' '----------------' '----------------' '----------------'
+ """.stripMargin)
+
+
+}
@@ -0,0 +1,9 @@
+package jp.enrapt.margx.board
+
+/**
+ * 牌
+ */
+class Tile {
+
+
+}
@@ -0,0 +1,26 @@
+# In this file you can override any option defined in the reference files.
+# Copy in parts of the reference files and modify as you please.
+akka {
+ # Event handlers to register at boot time (Logging$DefaultLogger logs to STDOUT)
+ event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
+ # Log level used by the configured loggers (see "event-handlers") as soon
+ # as they have been started; before that, see "stdout-loglevel"
+ # Options: ERROR, WARNING, INFO, DEBUG
+ loglevel = DEBUG
+ # Log level for the very basic logger activated during AkkaApplication startup
+ # Options: ERROR, WARNING, INFO, DEBUG
+ stdout-loglevel = DEBUG
+
+ actor {
+ default-dispatcher {
+ # Throughput for default Dispatcher, set to 1 for as fair as possible
+ throughput = 10
+ }
+ }
+ remote {
+ server {
+ # The port clients should connect to. Default is 2552 (AKKA)
+ port = 2562
+ }
+ }
+}
@@ -0,0 +1,14 @@
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="debug">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
@@ -0,0 +1,22 @@
+package jp.enrapt.margx
+import com.typesafe.scalalogging.slf4j.Logging
+
+object Runner extends App with Logging {
+
+ logger.debug(
+ """
+ | .----------------. .----------------. .----------------. .----------------. .----------------.
+ || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |
+ || | ____ ____ | || | __ | || | _______ | || | ______ | || | ____ ____ | |
+ || ||_ \ / _|| || | / \ | || | |_ __ \ | || | .' ___ | | || | |_ _||_ _| | |
+ || | | \/ | | || | / /\ \ | || | | |__) | | || | / .' \_| | || | \ \ / / | |
+ || | | |\ /| | | || | / ____ \ | || | | __ / | || | | | ____ | || | > `' < | |
+ || | _| |_\/_| |_ | || | _/ / \ \_ | || | _| | \ \_ | || | \ `.___] _| | || | _/ /'`\ \_ | |
+ || ||_____||_____|| || ||____| |____|| || | |____| |___| | || | `._____.' | || | |____||____| | |
+ || | | || | | || | | || | | || | | |
+ || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |
+ | '----------------' '----------------' '----------------' '----------------' '----------------'
+ """.stripMargin)
+
+
+}
@@ -0,0 +1,48 @@
+package jp.enrapt.margx.player
+
+import akka.actor._
+import scala.util.{Success, Failure}
+import scala.concurrent._
+import java.util.concurrent.{ Executors, ExecutorService, Executor }
+
+/**
+ * プレイヤー
+ */
+object Player {
+
+ val es = Executors.newFixedThreadPool(2)
+ implicit val ec = ExecutionContext.fromExecutorService(es)
+}
+
+class Player extends Actor {
+
+ import Player._
+
+ def expensiveCalculation(): Int = {
+ println("expensiveCalculation()")
+ 1
+ }
+
+ def expensiveCalculation(sender: ActorRef): Int = {
+ println("expensiveCalculation()" + sender)
+ 2
+ }
+
+ def receive = {
+
+ case _ =>
+ // Completely safe, "self" is OK to close over
+ // and it’s an ActorRef, which is thread-safe
+ Future { expensiveCalculation() } onComplete {
+ case Success(result) doSomethingOnSuccess(result)
+ case Failure(failure) doSomethingOnFailure(failure)
+ }
+
+ // Completely safe, we close over a fixed value
+ // and it’s an ActorRef, which is thread-safe
+ val currentSender = sender
+ Future { expensiveCalculation(currentSender) }
+
+ }
+
+}
View
@@ -0,0 +1,79 @@
+import sbt._
+import Keys._
+import scala.Console
+
+object ApplicationBuild extends Build {
+
+ println(Console.RED + """
+ | _______ ______ ___ ____ ______
+ | / ____/ | / / __ \/ | / __ \/_ __/
+ | / __/ / |/ / /_/ / /| | / /_/ / / /
+ | / /___/ /| / _, _/ ___ |/ ____/ / /
+ |/_____/_/ |_/_/ |_/_/ |_/_/ /_/
+ """.stripMargin + Console.RESET)
+
+ val appScalaVersion = "2.10.0"
+
+ // --- Setting keys
+ val appResolvers = Seq(
+ "Sonatype OSS Releases" at "http://oss.sonatype.org/content/repositories/releases",
+ "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
+ "Java.net" at "http://download.java.net/maven/2")
+
+ val appScalaOptions = Seq(
+ "-deprecation",
+ "-unchecked",
+ "-feature",
+ //"-optimize",
+ //"-Xprint:jvm",
+ "-Ymacro-debug-lite",
+ "-encoding", "utf-8")
+
+ val appDependencies = Seq(
+ "com.typesafe" %% "scalalogging-slf4j" % "1.0.0",
+ "org.slf4j" % "slf4j-api" % "1.7.1",
+ "ch.qos.logback" % "logback-classic" % "1.0.7",
+ "com.typesafe.akka" %% "akka-actor" % "2.1.0",
+ "org.scala-lang" % "scala-reflect" % "2.10.0")
+
+ lazy val root = Project(id = "margx",
+ base = file(".")).settings(
+ scalaVersion := appScalaVersion
+ ).aggregate(macro, board, player)
+
+ lazy val macro = Project(
+ id = "margx-macros",
+ base = file("modules/macro")
+ ).settings(
+ scalaVersion := appScalaVersion,
+ scalacOptions ++= appScalaOptions,
+
+ libraryDependencies ++= appDependencies,
+ resolvers ++= appResolvers
+ )
+
+ lazy val board = Project(
+ id = "margx-board",
+ base = file("modules/board")).settings(
+
+ // --- Scala
+ scalaVersion := appScalaVersion,
+ scalacOptions ++= appScalaOptions,
+
+ libraryDependencies ++= appDependencies,
+ resolvers ++= appResolvers
+ ).dependsOn(macro)
+
+ lazy val player = Project(
+ id = "margx-player",
+ base = file("modules/player")).settings(
+
+ // --- Scala
+ scalaVersion := appScalaVersion,
+ scalacOptions ++= appScalaOptions,
+
+ libraryDependencies ++= appDependencies,
+ resolvers ++= appResolvers
+ ).dependsOn(macro, board)
+}
+

0 comments on commit e3acc52

Please sign in to comment.