.net - Thread scheduler that can batch file operations on the same drive to the same thread? -
i'd use rx extensions handle parallelizing of long, file-bound operations.
the workflow along these lines:
- search given file pattern on several drives (let's assume each drive on separate physical device)
- for each matching file found, queue long file operation to same thread other files on same drive - minimizing random seeks.
- operations on files on different drives should queued different threads allow parallel processing.
my question is: rx scheduler (or combination of schedulers) should use ?
for this, it's useful realize each rx observable subscription works serially. is, single subscription of single observable, can sure onnext
delegate of 1 item completes before onnext
following item starts.
by default, onnext
delegate executed on current thread (the 1 calls onnext()
), can change using observeon()
.
what means you should create separate observable each physical drive , observe each on separate thread. 1 way that, if have single observable of operations execute use groupby()
.
which specific scheduler use? think pretty doesn't matter. observeon()
seems use schedulelongrunning()
if it's available, common schedulers means create new thread observing.
putting together, code like:
operations.groupby(op => op.drive) .select(o => o.observeon(taskpoolscheduler.default)) .do(o => o.subscribe(op => op.execute())) .subscribe();
(assuming operations
observable of operation type, has drive
property , execute()
method.)
Comments
Post a Comment