public ISynchronizationPoint < IOException > decode ( ByteBuffer buffer ) { SynchronizationPoint < IOException > result = new SynchronizationPoint <> ( ) ; new Task . Cpu < Void , NoException > ( "Decoding base 64" , output . getPriority ( ) ) { @ Override public Void run ( ) { if ( nbPrev > 0 ) { while ( nbPrev < 4 && buffer . hasRemaining ( ) ) previous [ nbPrev ++ ] = buffer . get ( ) ; if ( nbPrev < 4 ) { result . unblock ( ) ; return null ; } byte [ ] out = new byte [ 3 ] ; try { Base64 . decode4BytesBase64 ( previous , out ) ; } catch ( IOException e ) { result . error ( e ) ; return null ; } nbPrev = 0 ; if ( ! buffer . hasRemaining ( ) ) { write ( out , result ) ; return null ; } write ( out , null ) ; } byte [ ] out ; try { out = Base64 . decode ( buffer ) ; } catch ( IOException e ) { result . error ( e ) ; return null ; } while ( buffer . hasRemaining ( ) ) previous [ nbPrev ++ ] = buffer . get ( ) ; write ( out , result ) ; return null ; } } . start ( ) ; return result ; }
Start a new Task to decode the given buffer .