/*
   Copyright 2010 Aaron J. Radke

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
package cc.drx

/**this global is used to provide commonly used but hard to remember values at different levels*/
object Implicit{ //note the plural version is not used here since it is intended to only import single values
  //--execution contexts 
  // because I can never remember the fully qualified version of import scala.concurrent.ExecutionContext.Implicits.global
  // this is along the idea of the flat structure.  we are in scala, we mean one thing when we mean the implicit global context

  implicit lazy val ec:scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global
  implicit lazy val sc:java.util.concurrent.ScheduledThreadPoolExecutor = new java.util.concurrent.ScheduledThreadPoolExecutor(2)
   // TODO use a more complex scheduled executor? https://stackoverflow.com/a/37737385/622016
  // import java.util.concurrent.{ScheduledThreadPoolExecutor,Executors, ThreadPoolExecutor}
  // implicit lazy val sc = new ScheduledThreadPoolExecutor(2, Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy)
  2017-07-30("use ec16 instead","v0.2.16")
  implicit lazy val ecFixed16:scala.concurrent.ExecutionContext  = ec16
  private def ecFixed(n:Int) = ExecutionContext.fromExecutorService(java.util.concurrent.Executors.newFixedThreadPool(n))
  implicit lazy val ec8:scala.concurrent.ExecutionContext  = ecFixed(8)
  implicit lazy val ec16:scala.concurrent.ExecutionContext  = ecFixed(16)
  implicit lazy val ec32:scala.concurrent.ExecutionContext  = ecFixed(32)

  //--Default available implicit setting (these defaults can-not be overriden at a more specific scope why/how???)
  // implicit val defaultDrxRand     = Rand()
  // implicit val defaultDrxLogLevel = LogLevel.Debug
  implicit lazy val rand:Rand = Rand.defaultDrxRand

  //--log levels easier way to set the level
  implicit lazy val log:LogLevel = LogLevel.defaultDrxLogLevel
  implicit lazy val logDebug:LogLevel.Debug.type    = LogLevel.Debug
  implicit lazy val logInfo:LogLevel.Info.type      = LogLevel.Info
  implicit lazy val logNone:LogLevel.None.type      = LogLevel.None
  implicit lazy val logProgress:LogLevel.Progress.type  = LogLevel.Progress

  //--use like import Implicit.as._  //because I can never remember if we should be using Converesions or Converters :) and what package they live

  //---easier way to remember as conversion methods TODO add drx convert functions for asDrx
  // object DrxConverters extends scala.collection.JavaConverters

  // object DrxConverters extends scala.jdk.CollectionConverters

  // import  scala.collection.JavaConverters  
  // import scala.jdk.CollectionConverters._

  // import scala.collection.convert._ //easier way to remember as conversion methods TODO add drx convert functions for asDrx
  // object DrxConverters extends DecorateAsJava with DecorateAsScala // this is essentially scala.collection.JavaConverters
  // object as extends DecorateAsJava with DecorateAsScala // this is essentially scala.collection.JavaConverters but a much easier way to remember the conversion methods TODO add drx convert functions for asDrx
}