ZFFramework
 
Loading...
Searching...
No Matches
ZFThread_zfasyncIO.h File Reference

thread utility More...

#include "ZFThreadPool.h"

Go to the source code of this file.

Classes

class  ZFAsyncIOResumable
 resumable state for zfasyncIO More...
 
class  ZFThreadPoolForIO
 the thread pool for zfasyncIO More...
 

Functions

zfautoT< ZFTaskIdzfasyncIOCustom (const ZFListener &callback, const ZFListener &finishCallback=(zft_zfnull))
 util to perform IO in ZFThreadPoolForIO
 
zfautoT< ZFTaskIdzfasyncIO (const ZFOutput &output, const ZFInput &input, const ZFListener &finishCallback=(zft_zfnull), const ZFListener &progressCallback=(zft_zfnull), ZFAsyncIOResumable *resumable=(zft_zfnull))
 util to perform IO in ZFThreadPoolForIO
 

Detailed Description

thread utility

Function Documentation

◆ zfasyncIOCustom()

zfautoT< ZFTaskId > zfasyncIOCustom ( const ZFListener & callback,
const ZFListener & finishCallback = (zft_zfnull) )
extern

util to perform IO in ZFThreadPoolForIO

callback would run in new thread, finishCallback would run in ZFThread::mainThread

for the callback:

for the finishCallback:

when ZFTaskId::stop called after this method, the callback may or may not be canceled, but finishCallback would be canceled

◆ zfasyncIO()

zfautoT< ZFTaskId > zfasyncIO ( const ZFOutput & output,
const ZFInput & input,
const ZFListener & finishCallback = (zft_zfnull),
const ZFListener & progressCallback = (zft_zfnull),
ZFAsyncIOResumable * resumable = (zft_zfnull) )
extern

util to perform IO in ZFThreadPoolForIO

for the finishCallback:

for the progressCallback:

when ZFTaskId::stop called after this method, the callback may or may not be canceled, but finishCallback would be canceled

if you want to make the IO resumable:

  • input and output must support ZFIOCallback::ioSeek
  • first time:
    • pass a non-null resumable
    • when stopped failed or canceled, do not remove output file, and store or serialize the resumable object
  • to resume state: