Channel doesn't shutdown

21 views
Skip to first unread message

Piotr Zolnierek

unread,
Jul 6, 2012, 11:30:41 PM7/6/12
to loop...@googlegroups.com
I have this code below, where I am appending to a list in a channel, but sending -1 won't shutdown, and the app never exits. What am I doing wrong?

require channels

append(msg) =>
  -1                                  : @shutdown
  @print                              : print(mem[@values])
  *         | mem[@values] == Nothing : mem[@values] = [msg]
            | else                    : push(mem[@values], msg) 
  where
    mem     : channel_memory() 
  
main ->
  channel(@bucket, append, { @serialize: true}),
  @bucket.send(i) for i in [1..10],
  @bucket.send(@print),
  @bucket.send(-1)

Dhanji R. Prasanna

unread,
Jul 8, 2012, 9:01:53 PM7/8/12
to loop...@googlegroups.com
Hmm, can you verify that it is not shutting down? i.e. try sending it a print command after the -1.

I suspect this may be because the global threadpool gets spun up and then is keeping main open as it is a daemon pool. In this case, a simple fix would be to call exit(0) instead of returning @shutdown.

Piotr Zolnierek

unread,
Jul 8, 2012, 11:58:01 PM7/8/12
to loop...@googlegroups.com, loop...@googlegroups.com
Both are true... Printing after -1 works.

I added the exit to the event in the function, but that exits the app altogether, so that won't work if I just want to shutdown this one channel 


Piotr
Reply all
Reply to author
Forward
0 new messages