-1

How can i stop(interrupt) a fiber using c++ boost?

for example

fiber.stop()

How can i execute fiber join(time) using c+ boost(the default api dont accept a maximun time for waiting) ? for example:

fiber.join(1000);

it is possible to suspend a fiber , serialize it on disk , then reload it in the system?

1 Answers1

0

boost.fiber is modeled after std::threads's API - no interrupt function and not timed join.

You can't serialize a fiber because this would mean serializing the stack of the fiber which is not possible ... at least not without compiler support.

Stack serilization is not recommended because the compiler would have to take care about pointers to objects allocated on the stack, e.g. the objects must be re-allocated at the same addresses or the pointer must be re-written after deserializing the fiber (reloading).

RAII violations will be easily possible etc ...

xlrg
  • 1,994
  • 1
  • 16
  • 14
  • I dont agree with your opinion. 1) to create a fiber model very advanced can permit to use the same library at OS level or very low level : this pemits to solve all the actual problems related with languages incompatibilities with fibers and interoperability. 2) the serialization happens just before fiber status is removed from thread so you havent to save the absolute pointer addresses but just the relative offsets in memory. You can create a serialized portable status. If you want you can do it. it is not impossible. The advantage about it is impressive. – Bianca Mattiolo Jan 17 '18 at 13:40
  • C++11 did not provide std::thread interruption, guess why ... Serializing the stack would open the door for violating the RAII. – xlrg Jan 22 '18 at 09:24
  • Yes , for this reason the fiber might be created not inside compiler , but inside OS. Because it solve the violation problem but open the door to a world of possibilities. For this reason the way to create fiber in the language is not the better way: because it limits the possibilities offered by fibers(serialization, task migration,....).The compiler eventually can handle a 2-level serialization describing data types,.... – Bianca Mattiolo Jan 23 '18 at 15:22