GRAYBYTE WORDPRESS FILE MANAGER1865

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /opt/hc_python/lib/python3.12/site-packages/greenlet/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /opt/hc_python/lib/python3.12/site-packages/greenlet//TMainGreenlet.cpp
/* -*- 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"



// Protected by the GIL. Incremented when we create a main greenlet,
// in a new thread, decremented when it is destroyed.
static Py_ssize_t G_TOTAL_MAIN_GREENLETS;

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
{
    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)
{
    if (this->_thread_state) {
        // we've already traversed main, (self), don't do it again.
        int result = this->_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

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
May 23 2025 08:31:29
root / root
0755
__pycache__
--
May 23 2025 08:31:29
root / root
0755
platform
--
May 23 2025 08:31:29
root / root
0755
tests
--
May 23 2025 08:31:29
root / root
0755
CObjects.cpp
3.426 KB
May 23 2025 08:31:29
root / root
0644
PyGreenlet.cpp
22.892 KB
May 23 2025 08:31:29
root / root
0644
PyGreenlet.hpp
1.429 KB
May 23 2025 08:31:29
root / root
0644
PyGreenletUnswitchable.cpp
4.272 KB
May 23 2025 08:31:29
root / root
0644
PyModule.cpp
8.386 KB
May 23 2025 08:31:29
root / root
0644
TBrokenGreenlet.cpp
0.997 KB
May 23 2025 08:31:29
root / root
0644
TExceptionState.cpp
1.327 KB
May 23 2025 08:31:29
root / root
0644
TGreenlet.cpp
25.128 KB
May 23 2025 08:31:29
root / root
0644
TGreenlet.hpp
27.386 KB
May 23 2025 08:31:29
root / root
0644
TGreenletGlobals.cpp
3.188 KB
May 23 2025 08:31:29
root / root
0644
TMainGreenlet.cpp
3.199 KB
May 23 2025 08:31:29
root / root
0644
TPythonState.cpp
15.409 KB
May 23 2025 08:31:29
root / root
0644
TStackState.cpp
7.208 KB
May 23 2025 08:31:29
root / root
0644
TThreadState.hpp
18.683 KB
May 23 2025 08:31:29
root / root
0644
TThreadStateCreator.hpp
2.549 KB
May 23 2025 08:31:29
root / root
0644
TThreadStateDestroy.cpp
7.978 KB
May 23 2025 08:31:29
root / root
0644
TUserGreenlet.cpp
23.001 KB
May 23 2025 08:31:29
root / root
0644
__init__.py
1.683 KB
May 23 2025 08:31:29
root / root
0644
_greenlet.cpython-312-x86_64-linux-gnu.so
1.38 MB
May 23 2025 08:31:29
root / root
0755
greenlet.cpp
10.738 KB
May 23 2025 08:31:29
root / root
0644
greenlet.h
4.644 KB
May 23 2025 08:31:29
root / root
0644
greenlet_allocator.hpp
1.545 KB
May 23 2025 08:31:29
root / root
0644
greenlet_compiler_compat.hpp
4.244 KB
May 23 2025 08:31:29
root / root
0644
greenlet_cpython_compat.hpp
3.973 KB
May 23 2025 08:31:29
root / root
0644
greenlet_exceptions.hpp
4.397 KB
May 23 2025 08:31:29
root / root
0644
greenlet_internal.hpp
2.646 KB
May 23 2025 08:31:29
root / root
0644
greenlet_refs.hpp
33.629 KB
May 23 2025 08:31:29
root / root
0644
greenlet_slp_switch.hpp
3.123 KB
May 23 2025 08:31:29
root / root
0644
greenlet_thread_support.hpp
0.847 KB
May 23 2025 08:31:29
root / root
0644
slp_platformselect.h
3.751 KB
May 23 2025 08:31:29
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF