$30 off During Our Annual Pro Sale. View Details »

Future on Servlet #scala_ks

Future on Servlet #scala_ks

A presentation which shows you what the pain points are when working with Scala Future on Servlet environment

Kazuhiro Sera

August 01, 2015
Tweet

More Decks by Kazuhiro Sera

Other Decks in Programming

Transcript

  1. 'VUVSFPO4FSWMFU ,B[VIJSP4FSB!TFSBUDI 

  2. 8IPBN* w!TFSBUDI w4DBMJLF+%#$ʢʙʣ w4LJOOZ'SBNFXPSLʢʙʣ w4DBMBUSBɺKTPOTɺ4DBMBUF w. *OD4PGUXBSF%FWFMPQFS

  3. "HFOEB w8IZ'VUVSF w5ISFBEMPDBMUIJOHTJOUIFXJME w'VUVSFIBTJUTPXOUISFBEQPPM w4FSWMFU"1*`TNVUBCJMJUZ wSFDZDMJOHSFRVFTUJTTVFJOBTZODNPEF w4DBMBUSB%ZOBNJD4DPQFJTTVF w4LJOOZ`TTPMVUJPO

  4. 8IZ'VUVSF

  5. )PXUPVTF'VUVSF w $SFBUJOHBOEDPNQPTJOHNVMUJQMF 'VUVSFTBOEUIFO"XBJUSFTVMU 'VUVSF  SFUVSOJOH4FSWMFUSFTQPOTFTZODISPOPVTMZ w 3VOOJOH4FSWMFUTJOBTZODNPEF TVQQPSUFETJODF4FSWMFU

  6. 8IZ'VUVSF w6TJOH'VUVSFPO4FSWMFUJTOPUBMXBZT SFDPNNFOEFE w050) 'VUVSFJTUIFTUBOEBSEJO4DBMB OPX TPNFUJNFTOFFEFEUPTNPPUIMZ JOUFHSBUF'VUVSFCBTFEMJCSBSJFT w.ZOFBSB⒎BJSVTJOHOVMBCTDBMBPBVUI QSPWJEFSJOB4FSWMFUBQQMJDBUJPO

  7. 5ISFBEMPDBMUIJOHT JOUIFXJME

  8. 5ISFBEFENPEFM wPOFUISFBEGPSPOFSFRVFTU w"UISFBESFUVSOTBSFTQPOTFGPSBSFRVFTU w0OUIFTBNFUISFBEGPSXIPMFQSPDFTT w5ISFBEQPPMNBOBHFECZDPOUBJOFST w+BWB&&IBT+43UPT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UJPO IUUQTKDQPSHFOKTSEFUBJM JE

  19. SFDZDMJOHSFRVFTUT w*OGBDU SFRVFTUDBOCFSFDZDMFECFGPSF "TZOD$POUFYUDPNQMFUF  w$POUBJOFSTDPNNPOMZEPUIFlSFDZDMFzJO PSEFSUPBWPJEQFSGPSNBODFPWFSIFBE w*G*VOEFSTUBOESJHIU FWFOUIPVHI4FSWMFU TQFDTBZTTBNFBCPVUSFTQPOTF

      SFTQPOTFXPO`UCFSFDZDMFEVOUJMJUT DMPTVSFBUMFBTUJODBTFTPGTUBUFMFTT)551
  20. 4DBMBUSB %ZOBNJD4DPQFJTTVF

  21. Too easy to access this value everywhere including Future threads

    created on this Servlet
  22. None
  23. SFRVFTUSFTQPOTF w4DBMBUSB#BTF`TSFRVFTUSFTQPOTFBSF UISFBEMPDBM UPPEBOHFSPVTUPBDDFTT UIFNGSPN'VUVSFUISFBET w"MMUIF%4-BOEFYUFOTJPOTEPO`UBDDFQU SFRVFTUBTJNQMJDJUQBSBNFUFS w*OUIFJOJUJBMTUBUF UIJTEFTJHOJT SFBTPOBCMF

    'VUVSFEJEO`UFYJTUBUUIFUJNF  4JOBUSBDPODFQU
  24. 4LJOOZ`TTPMVUJPO

  25. 4LJOOZ

  26. TLJOOZFOHJOF

  27. TLJOOZFOHJOF w4UBSUFEBTB4DBMBUSBGPSL NVDIJNQSPWFE JOUFSOBMDPEFXIJMF%4-TPVSDF DPNQBUJCJMJUZJTLFQU w.BOZSFOBNJOHSFQBDLBHJOHBOEBGFX SFNPWBMPOUSBJUT w1BTTFEBMMUIF4DBMBUSB`TFYJTUJOHUFTUT w*`EMPWFUPDPOUSJCVUFTLJOOZFOHJOF`T JNQSPWFNFOUTUP4DBMBUSBUPP

  28. TUBCMFSFRVFTU

  29. TUBCMFSFRVFTU w4UBCMFBDDFTTUPSFBEPOMZEBUB SFRVFTU BUUSJCVUFTFWFOXIFOSFRVFTUIBTCFFO SFDZDMFEXIJMF'VUVSFPQTBSFTUJMMSVOOJOH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