Profile cover photo
Profile photo
Dorin Duminica
Success is nothing more than a reward for failures.
Success is nothing more than a reward for failures.
About
Dorin's posts

Post has shared content
HTTP Prompt is an interactive command-line HTTP client featuring autocomplete and syntax highlighting. Download url -> https://github.com/eliangcs/http-prompt
Animated Photo

Post has shared content
How to store private keys on disk or database, ensuring it won't be recoverable using forensic, even after beeing erased/overriden...

Post has shared content

Post has shared content
As I've continued to play with my async IO stuff, I've found that the programs do get a bit hard to read and maintain. You got handlers here and handlers there, and the flow between them is not easy to disentangle at first.

So I got inspired by Boost.Coroutine, which on Windows uses fibers to make "async look sync". The idea is you can have your cake and eat it: you get the benefits of async IO, while being able to write code which looks synchronous.

I just whipped this up in a couple of hours, so naming and implementation could probably do with a bit more polish, but here's the core result:

  inputStream := NewAsyncFileStream(Service, InputFilename, fcOpenExisting, faRead, fsRead);

  serviceContext := NewIOServiceCoroutineContext(Service);
  future := NewIOFuture(serviceContext);

  // queue the async read
  // this will return once the read has completed
  bytesRead := AsyncRead(inputStream, FBuffer, TransferAll(), future);

    if (not future.Result.Success) and (future.Result <> SystemResults.EndOfFile) then
  begin
      future.Result.RaiseException('Reading file');
  end;


So instead of passing a completion handler when performing an async operation, you pass a future. 

This future will switch to a fiber which just runs the IOService, that is waits for IO completion packets and executes the associated handlers.

When a "future completion handler" is executed it switches back to the fiber associated with the future (ie which made the async call) so that the calling code resumes as if the call was synchronous.

Here's the core of the file copy example: http://paste.ie/view/f0f6b7f2

For reference here's core of the old version using completion handlers: http://paste.ie/view/5d173758

Will brush it up and push it to the repo soon, along with TLS support (https, yeah baby yeah!).

Post has attachment
do you agree with the modern app developer, or with the old-timer?

I like go, I like the buzz words, but I like flexibility more, so, my solution would use golang and Postgresql(because magic!)

Post has shared content
once in a while, it's good to remind ourselves what really matter...
Photo

Post has shared content
Snap!

Post has shared content
My reaction when boss force me to give him root access because they "need it"

#Unix   #Linux   #IT   #Infosec   #Security   #Funny   #humor  
Animated Photo

Post has shared content
If engineers were treated like designers... via http://skeletonclaw.com/

#Funny   #design   #IT   #programming  
Photo
Wait while more posts are being loaded