fiber.cc (12787:1f6e23cddf71) fiber.cc (12920:76a7817ebea3)
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
28 */
29
30#include "base/fiber.hh"
31
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
28 */
29
30#include "base/fiber.hh"
31
32#if HAVE_VALGRIND
33#include <valgrind/valgrind.h>
34#endif
35
32#include <cerrno>
33#include <cstring>
34
35#include "base/logging.hh"
36
37using namespace std;
38
39namespace

--- 26 unchanged lines hidden (view full) ---

66{
67 startingFiber->start();
68}
69
70Fiber::Fiber(size_t stack_size) :
71 link(primaryFiber()),
72 stack(stack_size ? new uint8_t[stack_size] : nullptr),
73 stackSize(stack_size), started(false), _finished(false)
36#include <cerrno>
37#include <cstring>
38
39#include "base/logging.hh"
40
41using namespace std;
42
43namespace

--- 26 unchanged lines hidden (view full) ---

70{
71 startingFiber->start();
72}
73
74Fiber::Fiber(size_t stack_size) :
75 link(primaryFiber()),
76 stack(stack_size ? new uint8_t[stack_size] : nullptr),
77 stackSize(stack_size), started(false), _finished(false)
74{}
78{
79#if HAVE_VALGRIND
80 valgrindStackId = VALGRIND_STACK_REGISTER(stack, stack + stack_size);
81#endif
82}
75
76Fiber::Fiber(Fiber *link, size_t stack_size) :
77 link(link), stack(stack_size ? new uint8_t[stack_size] : nullptr),
78 stackSize(stack_size), started(false), _finished(false)
79{}
80
81Fiber::~Fiber()
82{
83 panic_if(stack && _currentFiber == this, "Fiber stack is in use.");
83
84Fiber::Fiber(Fiber *link, size_t stack_size) :
85 link(link), stack(stack_size ? new uint8_t[stack_size] : nullptr),
86 stackSize(stack_size), started(false), _finished(false)
87{}
88
89Fiber::~Fiber()
90{
91 panic_if(stack && _currentFiber == this, "Fiber stack is in use.");
92#if HAVE_VALGRIND
93 VALGRIND_STACK_DEREGISTER(valgrindStackId);
94#endif
84 delete [] stack;
85}
86
87void
88Fiber::createContext()
89{
90 // Set up a context for the new fiber, starting it in the trampoline.
91 getcontext(&ctx);

--- 57 unchanged lines hidden ---
95 delete [] stack;
96}
97
98void
99Fiber::createContext()
100{
101 // Set up a context for the new fiber, starting it in the trampoline.
102 getcontext(&ctx);

--- 57 unchanged lines hidden ---