ultraq / redhorizon

Recreating the original 2D Command & Conquer games
Apache License 2.0
6 stars 4 forks source link

Create a "cancellable" task/object #20

Closed ultraq closed 4 years ago

ultraq commented 4 years ago

It looks like FutureTask already has a lot of methods on it to create a cancellable task to run on a different thread. Instead of continuing with my custom Worker, maybe try use a FutureTask instead so I don't have to rebuild these threading primitives?

ultraq commented 4 years ago

Had a look at it, and the cancellation status can really only be queried from the thing that created the FutureTask, rather than the task itself, unless I want to make use of InterruptedExceptions 😕 I think what I really need here is some kind of "Cancellable" object, of which I have a few right now (the various engine subsystems, and the decoding tasks), so maybe I should expand on that concept and find a way to implement it

ultraq commented 4 years ago

Having a look at the different implementations so far, I'm going to close this one without doing anything. Each one is subtley different in their own way (Workers, Engines, Playable media), and trying to unify them might just make things worse.