Thanks. I guess Michael was keen to get rid of the warning. Works fine
without the ClassTag.


On Tue, Jun 10, 2014 at 3:13 AM, Patrik Nordwall <[email protected]>
wrote:

> Difference between String and Int might be boxing.
> I would not complicate it with ClassTag.
>
> /Patrik
>
>
> On Mon, Jun 9, 2014 at 6:48 PM, Richard Rodseth <[email protected]>
> wrote:
>
>> I'm implementing this pattern using Michael Pollmeier's contribution:
>>
>> https://github.com/mpollmeier/akka-patterns
>>
>> and have run into some problems along the way. The first was my error. I
>> overrode the iterator with a def instead of a val, and as a result the
>> Master never advanced through the Epic items.
>>
>>   type Work = String
>>
>>   val tasks = Seq("one", "two", "three", "four", "five", "six", "seven")
>>
>>   val epic = new Epic[Work] { override val iterator =  tasks.iterator }
>> // Note must be val
>>
>>  master ! epic
>>
>> Fixed that. Now, I'm trying with an Epic consisting of a range of ints:
>>
>>  type Work = Int
>>
>>   val tasks = Range(1,100)
>>
>>   val epic = new Epic[Work] { override val iterator =  tasks.iterator }
>> // Note must be val
>>
>>   master ! epic
>>
>> In this case, the pattern matching in the abstract worker fails. In the
>> code below the "Worker received other" message I added is logged. The
>> abstract worker has this ClassTag/manifest stuff that I don't yet
>> understand. Is there some reason that would work when type Work = String
>> but not when type Work = Int ?
>>
>> I notice that Derek Wyatt's version of the pattern (which represents work
>> items as a queue rather than an Iterable) uses type Any within the
>> PerformWork message.
>>
>>
>> https://github.com/derekwyatt/akka-worker-pull/blob/master/src/main/scala/Master.scala
>>
>> Any thoughts?  Here's the worker class from Michael Pollmeier (with minor
>> mods):
>>
>> abstract class Worker[T: ClassTag](val master: ActorRef)(implicit
>> manifest: Manifest[T]) extends Actor with ActorLogging {
>>
>>   implicit val ec = context.dispatcher
>>
>>
>>   override def preStart {
>>
>>     master ! RegisterWorker(self)
>>
>>     master ! GimmeWork
>>
>>   }
>>
>>
>>   def receive = {
>>
>>     case WorkAvailable =>
>>
>>       log.info(s"Worker $self received work available message")
>>
>>       master ! GimmeWork
>>
>>     case PerformWork(work: T) => {
>>
>>       // haven't found a nice way to get rid of that warning
>>
>>       // looks like we can't suppress the erasure warning:
>> http://stackoverflow.com/questions/3506370/is-there-an-equivalent-to-suppresswarnings-in-scala
>>
>>       log.info(s"Worker received work $work")
>>
>>       doWork(work) onComplete { case _ => master ! GimmeWork }
>>
>>     }
>>
>> // added by Richard while debugging
>>
>>     case m:Any =>
>>
>>       log.info(s"Worker received other $m")
>>
>>   }
>>
>>
>>   // abstract
>>
>>   def doWork(work: T): Future[_]
>>
>> }
>>
>> --
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ:
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>
> Patrik Nordwall
> Typesafe <http://typesafe.com/> -  Reactive apps on the JVM
> Twitter: @patriknw
>
> <http://www.scaladays.org/>
>
>  --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to