This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.scala.impatient | |
import org.junit.{Assert, Test} | |
/** | |
* org.scala.impatient.CaseClassTest | |
* User: [email protected] | |
* Date: 13. 1. 4. | |
*/ | |
class CaseClassTest { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kr.kth.commons.slf4j | |
import org.slf4j.{Logger => Slf4jLogger, Marker} | |
import annotation.varargs | |
/** | |
* Scala를 위한 Logger 입니다. | |
* User: [email protected] | |
* Date: 13. 1. 6. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kr.kth.commons.slf4j | |
import org.slf4j.Marker | |
import annotation.varargs | |
/** | |
* 로그를 사용할 클래스에서 MixIn 방식으로 상속해서 사용하면 됩니다. ( class A extends Logger ... ) | |
* User: [email protected] | |
* Date: 13. 1. 6. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Currency(value: Double, unit: String = "USD") | |
@Test | |
def extractorMatch() { | |
val amt = new Currency(29.95, "EUR") | |
amt match { | |
case Currency(amount, "USD") => log.debug(s" $$$amount") | |
case Currency(amount, "EUR") => log.debug(s"€$amount") | |
case _ => log.debug(amt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kr.kth.commons.slf4j | |
import org.slf4j.{Logger => Slf4jLogger, Marker} | |
import annotation.varargs | |
/** | |
* Scala를 위한 Logger 입니다. | |
* User: [email protected] | |
* Date: 13. 1. 6. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kr.kth.commons.slf4j | |
import org.slf4j.Marker | |
import annotation.varargs | |
/** | |
* 로그를 사용할 클래스에서 MixIn 방식으로 상속해서 사용하면 됩니다. ( class A extends Logger ... ) | |
* User: [email protected] | |
* Date: 13. 1. 6. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kr.kth.commons.slf4j | |
import org.junit.Test | |
/** | |
* User: [email protected] | |
* Date: 13. 1. 8 | |
*/ | |
class LoggingTest extends Logging { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def runUnitAsParallel(count: Int)(block: => Unit) { | |
log.debug("멀티스레드 환경에서 메소드들을 [{}] 번 실행합니다.", count) | |
try { | |
val latch = new CountDownLatch(count) | |
val pc = collection.parallel.mutable.ParArray.iterate(0, count)(x => x) | |
pc.tasksupport = new ThreadPoolTaskSupport() | |
pc map { | |
_ => { | |
block | |
latch.countDown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static ExecutorService newExecutorService() { | |
return Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); | |
} | |
@SafeVarargs | |
public static void runTasks(int count, Runnable... runnables) { | |
ExecutorService executor = newExecutorService(); | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static ExecutorService newExecutorService() { | |
return Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); | |
} | |
public static void runTasks(int count, final Runnable runnable) { | |
ExecutorService executor = newExecutorService(); | |
try { | |
final CountDownLatch latch = new CountDownLatch(count); |
OlderNewer